On Wed, 3 Sep 2003 12:54:07 +0800, [EMAIL PROTECTED] (Jaws) wrote:

>Hi all,
>
>I am currently using Net::SSH::Perl module to login in my remote machine.
>Below is my code:
>
>==================================
>#!/usr/bin/perl
>
>use Net::SSH::Perl;
>
>$user="jaws";
>$pass="password";
>$host="111.222.333.444";
>
>my $ssh = Net::SSH::Perl->new($host,"'1,2'");
>$ssh->login($user, $pass);
>$ssh->cmd("my_command");
>==================================
>
>the output of the last line requires me to input username and password. How
>can do it using this module? I've tried to search in the manual of the
>package but i didn't find one to answer my question and even in the web so i
>decided to ask help from you.

#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;

my $user = "zz";
my $password = "ztest";
my @hosts = qw(localhost zentara.zentara.net);

foreach my $host (@hosts){
my $cmd = "/usr/bin/uptime";
my $ssh = Net::SSH::Perl->new( $host, port => 22 ,debug => 1);
$ssh->login($user,$password);

my($out) = $ssh->cmd($cmd);
my ($time,$uptime) = (split /\s+/,$out)[1,3];
chop $uptime;
print "$out\n";
print "$host has been up $uptime\n";
}
 




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to