Thread Problem mit Net::SSH::Perl (16 answers)
Opened by tecker at 2008-10-22 17:30

tecker
 2008-11-26 16:55
#116631 #116631
User since
2008-02-26
77 Artikel
BenutzerIn
[Homepage] [default_avatar]
"Was lange wehrt ...."

Habs hinbekommen und bastel grad noch an einem schicken Interface um alles mit Perl/CGI zu machen.

Wen es interessiert ... mein funktionierendes Skript:

Code (perl): (dl )
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
#!/usr/bin/perl

use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $user = $ARGV[0];
my $password_old = $ARGV[1];
my $password_new = $ARGV[2];
my $host = $ARGV[3];

use Net::SSH::Expect;

my $ssh = Net::SSH::Expect->new (

   host => "$host",
   user => "$user",
   password => "$password_old",
   raw_pty => 1,

);

my $login_output = $ssh->login();

$ssh->exec("stty raw -echo");

$ssh->send("passwd");
$ssh->waitfor('password:\s*\z', 1) or die "prompt 'password' not found after 1 second";
$ssh->send("$password_old");
$ssh->waitfor(':\s*\z', 1) or die "prompt 'New password:' not found";
$ssh->send("$password_new");
$ssh->waitfor(':\s*\z', 1) or die "prompt 'Confirm new password:' not found";
$ssh->send("$password_new");
my ($before_match, $match) = $ssh->waitfor('>\s*\z', 1);  # waitfor() in a list context

View full thread Problem mit Net::SSH::Perl