in reply to Passing the shell script in ssh->cmd option

A little more context for you request would be helpful. If the shell script is housed on the remote server, you should be able to just call it. If it is local, a shell script is just a series of shell commands so there should be nothing preventing you from executing it remotely line-by-line. Have you attempted to implement this yet?
  • Comment on Re: Passing the shell script in ssh->cmd option

Replies are listed 'Best First'.
Re^2: Passing the shell script in ssh->cmd option
by saravanansh (Initiate) on Dec 26, 2008 at 13:28 UTC
    Local server is A and Remote Server is B Shell Script is housed on the local server A. for example we have a script called test.sh in local server A It is possible to pass this test.sh script to ssh->cmd option ssh->cmd(test.sh) whether ssh->cmd option will accept shell script as argument syntax -> ssh RemoteServer LocalScript example -> ssh RemoteB test.sh I want to run above sequence using Net::SSH and ssh->cmd option

      You cannot just pass a file name to cmd and expect it to read the file, parse it, transmit it and execute it. See Net::SSH::Perl. In particular, note that each string passed to cmd is executed in an independent session. The easiest solution to your proposal is to copy the script to the remote server, so it can be invoked with a single command. Something along these lines could also function for you:

      open(FILEHANDLE, '<test.sh'); my @file = <FILEHANDLE>; close FILEHANDLE; ssh->cmd(join ';', @file);