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

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
  • Comment on Re^2: Passing the shell script in ssh->cmd option

Replies are listed 'Best First'.
Re^3: Passing the shell script in ssh->cmd option
by kennethk (Abbot) on Dec 26, 2008 at 15:45 UTC

    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);