Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Net::SSH::Perl Help

Reply
Thread Tools

Net::SSH::Perl Help

 
 
blob
Guest
Posts: n/a
 
      09-05-2003
Hi all,

Below is my script that will be used to connect to a remote host and
change my password automatically:

===========================================
#!/usr/bin/perl


use strict();
use Net::SSH:erl;


$user="jaws";
$pass="password";
$host="xxx.xxx.xxx.xxx";
$old_password="password";
$new_password="newpass";


my $ssh = Net::SSH:erl->new($host,debug=>1,use_pty=>1);
$ssh->login($user, $pass);


$ssh->register_handler("stderr", sub {
my($channel, $buffer) = @_;
my $str = $buffer->bytes;


if ($str eq "Enter login password: ") {
$channel->send_data($old_password);
}


elsif ($str eq "New password: ") {
$channel->send_data($new_password);
}

elsif ($str eq "Re-enter new password: ") {
$channel->send_data($new_password);
}
});
$ssh->cmd('passwd');
==========================================

After running the program, my password didnt changed I was still able to
connect using the old password.

Does anybody has an idea what's missing or wrong with my script?

Thanks.

Jaws

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
HELP - HELP - HELP =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?= ASP .Net 4 03-09-2006 12:46 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 1 07-16-2004 01:12 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 0 07-16-2004 10:00 AM
HELP! HELP! HELP! Opening Web Application Project Error =?Utf-8?B?dHJlbGxvdzQyMg==?= ASP .Net 0 02-20-2004 05:16 PM



Advertisments