Leser: 20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/perl
use strict;
use warnings;
use English '-no_match_vars';
use Carp;
use Data::Dumper;
use Net::SSH2;
$Data::Dumper::Terse = 1;
$Data::Dumper::Useqq = 1;
$OUTPUT_AUTOFLUSH = 1;
my $ssh = Net::SSH2->new(trace => -1);
#$ssh->debug(1);
$ssh->connect('sw209a');
$ssh->auth_password('username','password') or carp $ssh->error;
$ssh->timeout(500);
my $chan = $ssh->channel();
$chan->pty('tty');
#$chan->pty('tty',{ echo => 0, vintr => ord('k') } );
$chan->blocking(0);
$chan->shell();
print {$chan} "\n";
_out ($chan);
print {$chan} "displ version\n";
_out($chan);
$ssh->disconnect;
sub _out {
my $ch = shift;
while (my $l = <$ch> ) {
chomp $l;
unless ( $l =~ /^\<\w+\>$/smx ) {
print "$l\n";
} ;
}
return;
}
$ssh->timeout(5);