Unix/Linux Go Back    

Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Problem with feeding password while changing to root user

Shell Programming and Scripting

change user, feed password automatically

Closed Linux or Unix Question    
Thread Tools Search this Thread Display Modes
Old Unix and Linux 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-

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

Last edited by Scott; 01-16-2013 at 05:34 AM.. Reason: Code tags
Sponsored Links
Old Unix and Linux 01-16-2013
Scott's Unix or Linux Image
Scott Scott is online now Forum Staff  
Join Date: Jun 2009
Last Activity: 26 May 2016, 6:16 PM EDT
Location: Zürich
Posts: 8,591
Thanks: 339
Thanked 1,087 Times in 944 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 06:19 PM.