Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Net::OpenSSH changing directory does not work properly

by keszler (Priest)
on Dec 07, 2011 at 10:53 UTC ( #942212=note: print w/replies, xml ) Need Help??


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

Net::SSH2, unlike Net::OpenSSH, provides a 'shell' method for a persistent connection allowing multiple commands. See A little demo for Net::SSH2 for an example.

  • Comment on Re: Net::OpenSSH changing directory does not work properly

Replies are listed 'Best First'.
Re^2: Net::OpenSSH changing directory does not work properly
by salva (Abbot) on Dec 07, 2011 at 11:04 UTC
    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 && ....

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942212]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2016-10-01 23:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (9 votes). Check out past polls.