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?

3
  • 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 9, 2014 at 13:19
  • Still not working. And i do not use <. That was just for example.
    – Ciprian
    Aug 9, 2014 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 9, 2014 at 15:30

1 Answer 1

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.

1
  • 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 9, 2014 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .