[Ssh-sftp-perl-users] net::ssh::perl interface.
Brought to you by:
dbrobins
|
From: edward v. <eve...@ve...> - 2004-08-26 23:42:00
|
In reading the documentation on the "cmd" meathod I see:
------------
Runs the command $cmd on the remote server and returns the stdout, stderr, and exit status of that command.
If $stdin is provided, it's supplied to the remote command $cmd on standard input.
NOTE: the SSH-1 protocol does not support running multiple commands per connection, unless those commands are chained together so that the remote shell can evaluate them. Because of this, a new socket connection is created each time you call cmd, and disposed of afterwards. In other words, this code:
my $ssh = Net::SSH::Perl->new("host1");
$ssh->login("user1", "pass1");
$ssh->cmd("foo");
$ssh->cmd("bar");
will actually connect to the sshd on the first invocation of cmd, then disconnect; then connect again on the second invocation of cmd, then disconnect again.
Note that this does not apply to the SSH-2 protocol. SSH-2 fully supports running more than one command over the same connection.
------
My problem is that I am using SSH-2 and I still get a new connection for each command I execute. What do I have to do to issue multiple commands over the same connection.
Example:
ssh->cmd("pwd");
output is "/home/here".
ssh->cmd("cd cur");
ssh->cmd("pwd");
output is "/home/here".
ssh->cmd("cd cur\npwd");
output is "/home/here/cur".
I have turned the debug option on and it confirms that I get a new connection each time I issue a cmd... Does anyone have a solution or suggestion on what I might try.
________________________________________________________________
Sent via the WebMail system at vegdahl.com
|