1
2
3
4
5
6
7
8
9
10
use Net::SSH::Perl;
my ($host,$user,$pw) = @_;
my $cmd = "ls";
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pw);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
return $exit;
$ssh->login($user, $pw);
1
2
3
4
5
6
7
8
9
10
11
12
use Net::SSH::Perl;
my ($host,$user,$pw) = @_;
my $rc = 0;
my $cmd = "ls";
my $ssh = Net::SSH::Perl->new($host);
$rc += $ssh->login($user, $pw);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
$rc += $exit;
return $rc;
1 2 3 4 5 6
eval { $ssh->login($user, $pw); }; if ($@) { say "Something went wrong: $@"; }
2012-07-31T09:36:40 AstralkeksAllerdings stirbt er - falls User/PW nicht zusammenpasst - schon bei der Zeile
Code: (dl )$ssh->login($user, $pw);