vote up 4 vote down star
1

On busy days,I'd like to run

$./configure && make && sudo make install && halt

on the night and go to bed,hoping the application would automatically installed.But what I see the next days is the screen where sudo ask me for the password.So how could I run sudo with password in one command line or is there any other method to do this?

thanks.

flag

3 Answers

vote up 5 vote down check

Yes, use the -S switch which reads the password from STDIN:

$echo <password> | sudo -S <command>

So for your case it would look like this:

$./configure && make && echo <password> | sudo -S make install && halt

of course, replace <password> with your password.

link|flag
5  
Obviously, one would not want to run this if there is any danger of someone else seeing the password in the shell history. – Brett Daniel Nov 9 at 3:16
vote up 4 vote down

You could replace your command line with this:

$sudo su

$./configure && make && make install && halt

You will be prompted for your password immediately, then the rest of the commands will run as superuser.

link|flag
2  
an alternate (and probably preferred) version of this: sudo sh -c "./configure && make && make install && halt" – ~quack Nov 9 at 3:51
vote up 2 vote down

You could also configure sudo with visudo to allow you user to use make as sudo without password.

User_Alias USERS = your_user
Cmnd_Alias CMDS = /usr/bin/make
USERS ALL = (ALL) NOPASSWD: CMDS
link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.