0

How can I create a text file to automatically run these commands:

sudo ap-hotspot start
sudo ap-hotspot configure
sudo ap-hotspot stop
sudo ap-hotspot restart

One file for each command.

I tried with creating a file ".sh" that contains:

#!/bin/bash
ap-hotspot start

Also used:

chown root:root <start-a-p>.sh
chmod 4755 <start-a-p>.sh

to give permissions.

But it doesn't work. Any other suggestions?

Ciprian
  • 1
  • 2
  • 1
    try `chmod +x .sh` and btw, if you are using the `<` in the file name, that may break it... – Tim Aug 09 '14 at 13:19
  • Still not working. And i do not use `<`. That was just for example. – Ciprian Aug 09 '14 at 13:40
  • For that then it would be simpler to run the entire script with sudo, a way to do it without prompting for password can be found [here](http://askubuntu.com/questions/155791/how-do-i-sudo-a-command-in-a-script-without-being-asked-for-a-password/155827#155827) – Wilf Aug 09 '14 at 15:30

1 Answers1

0

Try with following content in script (.sh)

#!/bin/bash
sudo /bin/bash -c "ap-hotspot start"

Make it a script by executing chmod +x filename.sh

and run it if you are in parent folder ./filename.sh or full path.

Web-E
  • 21,338
  • 12
  • 52
  • 93
  • I would like the script without `sudo` in it as I want to open so it can run the command without asking for the password. – Ciprian Aug 09 '14 at 14:25