pass the password to SU?? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

pass the password to SU??

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-27-2005
bikoyski bikoyski is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 10 May 2006, 9:38 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
pass the password to SU??

hi, i have a lot of su in my script. and it keeps asking for a password every single time. how can i pass the password to su command? any setup i need to do?

i used a redirect, not working.

su -username - c "command" < "password"

thanks for any help!
Sponsored Links
    #2  
Old 10-27-2005
Unbeliever Unbeliever is offline
Registered User
 
Join Date: Jul 2005
Last Activity: 14 September 2007, 11:54 AM EDT
Location: England
Posts: 183
Thanks: 0
Thanked 1 Time in 1 Post
You can't do this is a normal shell script and you shouldn't really since it involves putting clear text passwords in a text file.

If ther is no choice then you need to use something like expect (http://expect.nist.gov/)
Sponsored Links
    #3  
Old 10-27-2005
sysera sysera is offline
Registered User
 
Join Date: Feb 2004
Last Activity: 8 October 2009, 9:25 AM EDT
Posts: 92
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by bikoyski
hi, i have a lot of su in my script. and it keeps asking for a password every single time. how can i pass the password to su command? any setup i need to do?

i used a redirect, not working.

su -username - c "command" < "password"

thanks for any help!
Which user is running the script?
    #4  
Old 10-27-2005
bikoyski bikoyski is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 10 May 2006, 9:38 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
i'm logged in as 'a'.

but there are commands in the script that does a 'sed', 'rm', 'mv' , but 'a' is not the owner of the files. so i need to 'su' to the owner before i can do anything to the files.
Sponsored Links
    #5  
Old 10-27-2005
ispepalocacoc ispepalocacoc is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 2 November 2005, 9:58 PM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Look into using "sudo". You'll have to configure it properly, and you'll have to put in your password once, but it remembers it for a time, so all subsequent sudo calls won't require the password.
Sponsored Links
    #6  
Old 10-27-2005
sysera sysera is offline
Registered User
 
Join Date: Feb 2004
Last Activity: 8 October 2009, 9:25 AM EDT
Posts: 92
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by ispepalocacoc
Look into using "sudo". You'll have to configure it properly, and you'll have to put in your password once, but it remembers it for a time, so all subsequent sudo calls won't require the password.
This and I believe expect would also be a solution to your issue. However I wouldn't consider it as a very secure one as you'll have to keep a password in a file somewhere.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to pass the password as input parameter to scp eldonlck Shell Programming and Scripting 2 03-13-2012 12:52 AM
How to pass decrypted password to script Nick1971 Shell Programming and Scripting 1 10-17-2011 10:40 AM
Pass root password through script shahdeo Shell Programming and Scripting 7 11-12-2010 03:04 AM
pass a password to an application latenite Shell Programming and Scripting 4 07-19-2009 02:52 PM
SFTP - Pass password auti bullz26 Shell Programming and Scripting 10 05-29-2008 07:16 AM



All times are GMT -4. The time now is 12:12 AM.