bash scripting question
Hello,
I have a script that I wrote to check if the modem is connected or not. If connected it disconnects and vice versa. I wrote the script because my modem is a USB ADSL and I wanted an easy way to (dis)connect. I have to run the script as root, and don't want to chmod the app it calls. 1. How can I change to root in the script? (I tried su at the top but that quits the script once the password is typed) 2. Is it possible to get KDE to display 2 icons for the script like the trash icon, 2 state? Thanks in advance, Andy. |
Oh and before I forget, can you call GUI style message popups from bash?
|
Have you tried
Code:
su -c 'scriptname.sh' Keep in mind, Im still a newbie :) |
I mean that the script does some stuff then
su # inside the script then is supposed to carry on with more. Sorry if it was not clear the first time. |
Well. It's probably best to have 2 scripts: the second one for the root part, which you call from the first script with:
Code:
sudo /path/to/second/script Code:
<user> <hostname> = NOPASSWD: /path/to/second/script (1) Replace "<user>" with the name of the user you want to allow to run the script as root without entering the root password (2) Replace "<host>" with the hostname of the computer. "localhost" will not do (on my system at least), use the output of "hostname". Hope this helps. See "man sudo" and "man sudoers" for more information. |
All times are GMT -5. The time now is 01:09 PM. |