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?

  • 1
    try chmod +x <start-a-p>.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 – 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,418
  • 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