Is it possible to run one part of the ksh/sh script on one server then ssh to another server and continue with the rest of the script? Or is there a work-around?
I have a user with which I don't have to authenticate each time I access a server, so I can hop from one server to another without any keyboard interaction.
I've already tried this, trying to separate some logic into another script then :
MYSCRIPT="nohup ksh myscript.ksh > mylog.log &"
ssh servername ${MYSCRIPT}
I tried this but it doesn't seem to execute this script on another server.
The whole code above is part of a for
loop; I execute the same script for a list of servers.
For testing purposes, the list has two servers; for some weird and twisted reason, only the last (or second) server script works as I expect.
All servers can see myscript.ksh -- it is visible and executable to all of them.
It sounds like you want to run a sequence of commands on another server without having to log in multiple times. To accomplish this, you could do:
local_command sequence
ssh remote-server << End-Of-File
remote_command 1
remote_command 2
remote_command 3
End-Of-File
This would run remote_command 1
, and when it finishes, run remote_command 2
, then remote_command 3
all on the remote server
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments