The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
substr() thru awk Korn Shell Script sbryant Shell Programming and Scripting 4 01-24-2008 07:16 AM
Help with Korn Shell script heprox AIX 1 12-19-2005 10:04 AM
korn shell script pavan_test UNIX Desktop for Dummies Questions & Answers 3 10-27-2005 09:09 AM
korn shell script pavan_test UNIX for Dummies Questions & Answers 1 10-26-2005 10:17 AM
Multiple su - in Korn Shell script furrari Shell Programming and Scripting 2 07-30-2004 06:29 AM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-02-2001
Registered User
 

Join Date: Mar 2001
Location: Washington, DC
Posts: 7
Question su and password in a Korn shell script

Hi All,

In my shell script I want to use su - userid
and provide password for this user, but I don't know the syntax to do this, can anyone tell me what it is?

I have tried:
su - userid/password
and
su - userid password

but no luck...
Forum Sponsor
  #2 (permalink)  
Old 10-02-2001
Registered User
 

Join Date: Sep 2001
Location: Green Bay, WI
Posts: 66
as far as I know you can not su in a script.
the only way to do this is to use expect to automate the su or the perl telnet module to telnet in as a different user within the script , or use sudo to run a script as another user.

Hope this helps

Ed
  #3 (permalink)  
Old 10-03-2001
Registered User
 

Join Date: Dec 2000
Location: Greater Dallas area
Posts: 405
If the script is running as root I believe you can use 'su -c username' to change the owner of the process. The problem with using su and entering the password before completing a script is that a new shell is spawned for the new user, and the commands in the script after the su will not run until that shell is exited.
__________________
[url=http://chuckb.1le.net/]My website[/url]
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0