Friday, January 14, 2011

Akash Mahakode: Linux : Provide password to sudo on same prompt

Akash Mahakode: Linux : Provide password to sudo on same prompt: "Hi All, As we know whenever we need to execute some script/program on Mac/Linux with root permissions for a user, then we run that script wi..."

Thursday, January 13, 2011

Linux : Provide password to sudo on same prompt

Hi All,

As we know whenever we need to execute some script/program on Mac/Linux with root permissions for a user, then we run that script with "sudo". E.g

$sudo ./some_script
password:

After execution of the command on terminal, a password prompt comes and waits for user to provide password. I have been searching for the methodology that will not wait for password prompt. Because lots of coding efforts needs to be provided to provide password on "password" prompt.
So, the solution is simple, just type -

$ echo password | sudo -S ./some_script

I have sudo 1.7.0 version installed on my Ubuntu machine.
This will not wait for the password prompt and you would be able to run ./some_script with sudo permissions.