scripts with root priviliges
Hi,
I wrote a short script mounting/unmounting external sata drives or pen drives. I installed slackware on a new box, and the problem is that when I run the script as a normal user, I get the error about not having permissions to mount it (fair enough), but when I su and run the script as root the script can't be found. obviously it's not in the path, but I do not want to add normal_user/home/bin to root's path. I am sure some time ago I managed to do it without adding anything to the root's path. Obviously, I can always cd /home/bin/ and run the script, but that's not the point. thank you |
Hi,
Why not use su - on the mount command only and run the script as regular user? I.e: #!/bin/bash some code... more code... su - -c "mount -o loop -t iso9660 /data/Multimedia/" more code.... Su's -c switch lets you enter a command (man su for details). You will be asked for a password. By the way: If you use su instead of su -, root's environment is not parsed. PS: You could also install/configure sudo. Hope this helps. |
Quote:
[root@yourcomputer /] whereis ls then whatever the path is suggested by the command, put your script in there and then it will work like a normal linux command. Also remember, the permission should be 777 on the file, but mounting wont be allowed to any other user except root. Rgds, Rahul. |
Thanks guys, I will try both methods at home.
I know sudo is installed on my box, how do I configure it? thanks |
Hi,
I don't use sudo myself, but here are a few links: sudo setup guide man sudoers man sudo and last, but not least: sudo main page Hope this helps. |
thanks, I will play with it
|
All times are GMT -5. The time now is 06:25 PM. |