Jonathan Dye jonathan.dye@automationpartnership.com writes:
Is it possible to fire up ssh and run a remote command in a perl script, somthing like :
system("ssh <user>@<host>:/<command>");
the command would be system("ssh <user>@<host> <command>"); (or at least the ssh part is like that as I've not checked the perl system() command)
Remember to get the quoting right if you do it like that. An easier approach would be:
system("ssh", "<user>@<host>", "<command>");
...which the requirement for one level of quoting.
Would the above run the command then quit or stay logged in ?
It should return when the remote command returns and it's return code will be that of the remote command.
Not quite, it won't:
sfere$ ssh sfere exit 3 ; echo $? 3 sfere$ sh -c 'kill -KILL $$' ; echo $? Killed 137 sfere$ ssh sfere 'kill -KILL $$' ; echo $? 255 sfere$ ssh -V OpenSSH_3.4p1 Debian 1:3.4p1-1, SSH protocols 1.5/2.0, OpenSSL 0x0090603f