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

  Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
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-

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


Last edited by Scott; 01-16-2013 at 06:34 AM.. Reason: Code tags
Sponsored Links
    #2  
Old Unix and Linux 01-16-2013
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 5 March 2015, 3:44 AM EST
Location: Zürich
Posts: 8,525
Thanks: 336
Thanked 1,062 Times in 925 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

Unix or Linux Image 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 01:32 PM
changing user password as root on LDAP client SOl10/u7 ilikecows Solaris 1 08-05-2009 10:18 AM
Problem changing user password bbbngowc Linux 6 04-24-2009 02:28 PM
Changing root password zetadhell HP-UX 3 05-14-2007 07:42 AM
changing user password mayge AIX 0 07-12-2006 12:08 PM



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