http://www.perlmonks.org?node_id=942213


in reply to Re: Net::OpenSSH changing directory does not work properly
in thread Net::OpenSSH changing directory does not work properly

Net::OpenSSH does also support running a remote shell and it even allows to use Expect to interact with it.

But in my opinion, talking to a shell is harder and less reliable than running simple commands even if they have to be prepended with cd $path && ....

Replies are listed 'Best First'.
Re^3: Net::OpenSSH changing directory does not work properly
by keszler (Priest) on Dec 07, 2011 at 11:59 UTC

    Aha - I overlooked $ssh->open2pty. Thank you.

    I agree that for a handful of serial-dependent commands the shell overhead is excessive, but at some point I believe it becomes worthwhile.

      Actually, all the methods of Net::OpenSSH support running a shell, even if it doesn't make sense for several of them.

      Just, don't pass a command argument and you get a shell. For instance:

      $out = $ssh->capture({stdin_data => <<EOS}); ls foo this foo that rm -R / EOS # or... ($socket, $pid) = $ssh->open2socket; print $socket "ls\n"; while (<$socket>) { print }; waitpid($pid, 0);