Register
It is currently Mon Sep 01, 2014 5:28 pm

Pre-authorizing sudo, avoid script asking for password again


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Feb 16, 2012 1:10 pm   

Joined: Thu Feb 16, 2012 1:04 pm
Posts: 2
Hi,

I have a bashscript that I want to run shutdown when it's done. I just want to provide the sudo pass once, when I start. As it is now the script asks for the password in the beginning (when running sudo rsync), and then again when it's about to shutdown. That's a problem since the whole meaning is that it should shutdown on itself ...

Thankful for tips on how to solve this,

psb


Top
 Profile  
 PostPosted: Thu Feb 16, 2012 3:15 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 535
hi,

try
Code:
sudo -i 'rsync <options>
shutdown'


Top
 Profile  
 PostPosted: Mon Mar 12, 2012 4:44 am   

Joined: Thu Feb 16, 2012 1:04 pm
Posts: 2
Thanks Watael!

Will try it,

What does the ' do?

Best, petaspeedbeaver


Top
 Profile  
 PostPosted: Mon Apr 02, 2012 2:21 am   

Joined: Mon Feb 16, 2009 10:07 am
Posts: 19
Location: Paris - France
the ' (both in fact) are intended to include the <newline> to separate the commands I presume
that is : do the rsync <options> and then shutdown
I'm not sure this would work
try :
Code:
sudo -S rsync <options> < <( echo $passwd )
...
sudo -S shutdown < <( echo $passwd )


Top
 Profile ICQ YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP