Problem with feeding password while changing to root user | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Problem with feeding password while changing to root user

Shell Programming and Scripting


Tags
change user, feed password automatically

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-16-2013
mhmn mhmn is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 20 January 2013, 2:14 AM EST
Posts: 2
Thanks: 2
Thanked 0 Times in 0 Posts
Problem with feeding password while changing to root user

i want to change user to "root" from another user while running a script. how can i automatically feed the password? for example, i want to write a script say "script.sh"... it will first run the command "p" as mhmn user, and then it will change the user to "root" by using "su - root" command. at this point it asks for the password for root. say the password is "blue". i want to feed the p.w. automatically while it asks for it. inside script.sh it will look something like-

Code:
 
#p
#su - root 
(feed p.w. automatically here)
#p


Last edited by Scott; 01-16-2013 at 05:34 AM.. Reason: Code tags
Sponsored Links
    #2  
Old 01-16-2013
Scott's Avatar
Scott Scott is online now Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 26 July 2014, 11:09 AM EDT
Location: Zürich
Posts: 8,427
Thanks: 328
Thanked 1,029 Times in 900 Posts
That's not possible, except if the user is a member of the wheel group and PAM is configured to allow it.

Configuring sudo is probably the better way to go. Giving carte blanche access to root using su in this way is generally not a good idea.
The Following User Says Thank You to Scott For This Useful Post:
mhmn (01-16-2013)
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
Permission denied when changing root password after reset darkone_d1_2000 UNIX for Dummies Questions & Answers 0 06-25-2010 12:32 PM
changing user password as root on LDAP client SOl10/u7 ilikecows Solaris 1 08-05-2009 09:18 AM
Problem changing user password bbbngowc Linux 6 04-24-2009 01:28 PM
Changing root password zetadhell HP-UX 3 05-14-2007 06:42 AM
changing user password mayge AIX 0 07-12-2006 11:08 AM



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