R
roygbaba
I am tring to interact with sudo command but i cant seem to get it
right.
i took the example from the /eg directory from CPAN and tried to use it
, but nothing ....
can someone take a look at the code and suggest somthing?? I realy want
to gte this thing done .
#!/usr/bin/perl -w
use strict;
use Net::SSH:erl;
my ( $host , $username , $password );
$host="1.1.1.1";
$username="USER";
$password="PASS";
my $ssh = Net::SSH:erl->new($host, debug => 1, protocol => 2 ,
use_pty => 0);
$ssh->login($username, $password);
$ssh->register_handler("stderr", sub {
my($channel, $buffer) = @_;
my $str = $buffer->bytes;
print $str;
if ($str eq "Password:") {
$channel->send_data("$password\n");
}
$channel->send_data("$password\n");
});
$ssh->cmd('sudo tcsh');
right.
i took the example from the /eg directory from CPAN and tried to use it
, but nothing ....
can someone take a look at the code and suggest somthing?? I realy want
to gte this thing done .
#!/usr/bin/perl -w
use strict;
use Net::SSH:erl;
my ( $host , $username , $password );
$host="1.1.1.1";
$username="USER";
$password="PASS";
my $ssh = Net::SSH:erl->new($host, debug => 1, protocol => 2 ,
use_pty => 0);
$ssh->login($username, $password);
$ssh->register_handler("stderr", sub {
my($channel, $buffer) = @_;
my $str = $buffer->bytes;
print $str;
if ($str eq "Password:") {
$channel->send_data("$password\n");
}
$channel->send_data("$password\n");
});
$ssh->cmd('sudo tcsh');