Hello, I have been having problems with NET::SSH::Expect lately and I have always found it generally slow and buggy.
Upon doing some research, I found Net::OpenSSH. It appears to be working really fast and be reliable.
The only thing though is that I am having a problem running multiple commands within the same session(logging onto the device only once and run all the commands). Unless I mis-understood the documentation provided by Salvador Fandiņo, I have the following code which log's on (into a Cisco router by the way) and displays the login banner and then returns to my linux prompt.
#!/usr/bin/perl use strict; use IO::Pty; use Expect; use Net::OpenSSH; my $host = '10.0.0.1'; my @cmd = ('sh run', 'sh ver'); my $ssh = Net::OpenSSH->new($host); my ($pty, $pid) = $ssh->open2pty(@cmd) or die "unable to run remote command @cmd"; my $expect = Expect->init($pty);
I hope there is a good solution. I really want to move away from Net::SSH::Expect...
In reply to Net::OpenSSH multiple commands by mlebel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |