help with sudo and net::ssh:perl

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::perl;

my ( $host , $username , $password );
$host="1.1.1.1";
$username="USER";
$password="PASS";





my $ssh = Net::SSH::perl->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');
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top