Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a Shell Script Remotely

Status
Not open for further replies.

lresides

Programmer
Aug 9, 2001
7
US
Hi,
I am encountering a problem where I have built a shell script on one system (SYSTEM A)which executes a series of programs on that system and mails the results of those program back to me. If I execute the shell on SYSTEM A everything works just fine. However I am trying to make this an automated process so that I can execute the shell from SYSTEM B (both systems are AIX UNIX). I have put the line :

rsh SYSTEMA myshellscript

in my .profile on SYSTEM B.

Unfortunately the script doesn't work when executed in this fashion. It can't find any of the files for execution that it was able to find when I rsh'd to SYSTEM A and ran the script manually.

Any ideas or sources I should look at to resolve this? Thanks, Leigh
 
Are you using the relative or absolute path when calling any files or other programs from your script?
 
I've tried both ways. Unfortunately the programs that I'm running seem to require some of the exported variables that are available when I log on to the system manually.

It seems that if I can "rsh SYSTEMA" from SYSTEMB and execute the script (and I can) I should be able to
"rsh SYSTEMA myshellscript" from SYSTEMB and have it exeute the same way, but evidently not...
 
I think your problem is that rsh executes a command on the remote host - without logging in (admittedly it will do an rlogin if no command is specified).
If you require remote .profile variables to be used (as I suspect) then you should use a:
dot_space_.profile
at the beginning of your script. e.g.
= = = = = = = = = = = = =
£! /bin/ksh
. $HOME/.profile
£ Now do your stuff...
= = = = = = = = = = = = =

HTH.
 
Hi lresides,

when you 'rsh' a command on a remote box, that command does not have user specific environment variables set because no profile is loaded (much like if you "su userX").

You don't have a problem giving "myshellscript" on the server that the script resides on because your environment is set....so

either export the variables that you think might be the cause of your problems(PATH,LD_LIBRARY_PATH, etc, etc...) or create a non-interactive copy of your .profile and call it at the beginning of your script.

i.e.

. ./.profile

I've had problems similar to this, where even giving the absolute path still failed and I got around this by simply cd'ing into the directory where the script or exe resided. This was usually caused by poorly defined PATH's at system level or if it was a cron job, then nothing was defined in /etc/default/cron.

adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top