Passwords in Linux scripts?
Passwords in Linux scripts?
I would need to run "sudo su" in a script (.sh), but how can I include the password it needs? (No need to worry about security, the script will not launch nuclear weapons... ; )
- Roland -
Re: Passwords in Linux scripts?
What do you think about this?
sudo visudo
Where username is the user who executes the script.
sudo visudo
Code: Select all
username ALL=(ALL) NOPASSWD: ALL
http://www.amigalinux.org
http://www.supertuxkart-amiga.de
Running Linux on AmigaONEs can require some tinkering.
http://www.supertuxkart-amiga.de
Running Linux on AmigaONEs can require some tinkering.
Re: Passwords in Linux scripts?
Thanks for the tip! Unfortunately, it works only partially... If I open a Term window, I can now use 'sudo su' without password. But the script where I have 'sudo su' on the first line still doesn't work, except from 'root'. Is there a way to get some output from a script, error messages etc.?xeno74 wrote:What do you think about this?
sudo visudo
Where username is the user who executes the script.Code: Select all
username ALL=(ALL) NOPASSWD: ALL
- Roland -
Re: Passwords in Linux scripts?
Why sudo su? You can execute your script with sudo.
http://www.amigalinux.org
http://www.supertuxkart-amiga.de
Running Linux on AmigaONEs can require some tinkering.
http://www.supertuxkart-amiga.de
Running Linux on AmigaONEs can require some tinkering.
Re: Passwords in Linux scripts?
When I first tested the individual commands for the script in a terminal, one of them needed that I use "sudo su". Plain "sudo" was not able to run it. So I thought I have to have 'sudo su' as the first command in the script!xeno74 wrote:Why sudo su? You can execute your script with sudo.
But only after reading your comment above I understood that you speak about a different, "two-layer" approach, where the primary script is run via an auxiliary script with "sudo script_name". That indeed works and solved the problem - thank you !-)
- Roland -