The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-10-2007
buechler66 buechler66 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 14
Using 'su'

I host out of an Oracle Web application to the Unix command line. By default I am a user named 'ora9i'. I would like to call a script that logs me in as another user...I will know the username and password, run their .profile to access a couple of common environment variables, and then execute a command using the values of these variables. Is this possible within a single script? Is it possible at all?

I would like to:
  • su - my username/my password (i assume the su will run the .profile)
  • execute an OS command and pass certain environment variable as parameters of the command

Any suggestions would be very helpful. Thanks.
  #2 (permalink)  
Old 07-10-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
You could use a single command for that.
Code:
su - username -c "/path/to/command $ENV_VAR1 $ENV_VAR2"
The 'su -' will take care of the .profile and set the env variables. You just have to know what they are and pass them in to the command.
  #3 (permalink)  
Old 07-11-2007
buechler66 buechler66 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 14
Re: Using 'su' - What about the password prompt

Thanks, but what about the password? Won't this interactively prompt for a password? Is there a way to also pass in the password so that the command can be used in a script?

Thanks in advance.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0