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.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script to execute user command redtiger Shell Programming and Scripting 1 04-30-2008 06:53 PM
how to execute a batch script from shell script lakshmis10 Shell Programming and Scripting 1 10-17-2007 12:43 PM
How to restrict the number of commands user can execute rockysfr Shell Programming and Scripting 1 07-03-2007 01:53 PM
script execute or no execute Kespinoza97 Shell Programming and Scripting 4 06-23-2007 09:27 AM
Maint user cannot execute ping command kabeer_n UNIX for Dummies Questions & Answers 3 10-23-2006 11:01 PM

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 09-10-2007
aubtc aubtc is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 6
Execute internal script as different user

I have a script that I must run as user X and need to send the results to a different server as user Y (sftp). User Y has been set up to not require password authentication between the 2 servers. I would prefer to keep these in a single script, as our operations might have to run it from time to time and I would prefer to keep things simple.

Another thought was to have 2 scripts that poled a status file to see "whose" turn it was to execute.

Any suggestions?

Thanks
  #2 (permalink)  
Old 09-10-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
What is supposed to be executed by Y?

as user X

Code:
....

sftp ... Y@server <<EOF
.....
EOF

.....
  #3 (permalink)  
Old 09-11-2007
aubtc aubtc is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 6
Yes, sftp needs to be run as user Y. The main script is a start/stop process for a web based application (separate app and web servers). All the processes must be started or stopped as user X, but user Y must be used to send results to the other server detailing basically whose turn it is to run.

[app server script]
start environment (x)
start rmi (x)
sftp web (y)
wait till app continue
start scheduler (x)

[web server script]
wait till web
start web (x)
sftp app continue (y)
  #4 (permalink)  
Old 09-11-2007
kittielemieux kittielemieux is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 4
since everything else is run under user x, maybe you can just enclose the sftp command for user y in an su -c command
  #5 (permalink)  
Old 09-11-2007
aubtc aubtc is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 6
I am also trying to keep from storing the password of the User Y on the system as well and user X is not root.
  #6 (permalink)  
Old 09-11-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Try this

script starts as X

script then does SSH to other system as Y using private key as follows...

Code:
echo this is running as X here
ssh -i identity Y@other <<EOF
echo this script part will run as Y on the other machine
EOF
echo this is back running as X here
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 12:36 AM.


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