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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to run consecutive commands on different host

Status
Not open for further replies.

bgreen

Programmer
Feb 20, 2003
185
CA
Hi,

I need to run consecutive commands on a differnt host. I can use rsh but that only executes one command at a time.

in host1:

rsh <host2> command1
command2
command3
...

is there a way to run the command consecutivly <host2> then going back to <host1>?
 
Hi,
You can run
rsh host2 command&

Regards Boris
 
rsh works only if you want to run one command at a time. This will not work for what I need to do. I have to set some environment variables and then run a command. Therefore I need to stay on the particular host.
 
Can you place a script on host2 that sets the variables and executes your command?

Also, you might try adding the environmental variables to your command on host1, like:

rsh host2 "TZ=GMT date"

I don't run rsh, for security reasons, but that syntax works with ssh.



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
I have tried using rsh to run a script on host2 but ideally I would like to have it on the host1

rsh host2 abc.ksh
 
bgreen: one hacky method would be creating (storing) the script on host1, and when you need to run it then

rcp abc.sh host2:abc.sh
rsh host2:abc.sh

Well, this is not so pretty...

Or simply you can enumerate your commands between apostrofs, delimited by semicolons, like this:

rsh host2 ' echo first comman ; date ; echo I am the third '

but this way the number of commands is limited by the shell, as it has maximum command length.

AND FINALLY, oh yeah, I have found it :) You can simply run a ksh on the remote host (host2) and have its standard input open from host1

host1# cat scrip1_on_host1.sh | rsh host2 ksh


--Trifo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top