On Sat, 16 Aug 2003 17:25:15 -0700 (PDT), [EMAIL PROTECTED] (Titu Kim)
wrote:
>Hi,
> Thanks for your reply. My purpose is not only to
>run uptime. I need to write a script to log into other
>machines to grep the log file contents. Now, I log in
>one by one and grep the log. I want to use the script
>to log into all machine automatically to do this job.
>Do you have any suggestion to do this?
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;
my %hostdata = (
'localhost' => {
user => "zz",
password => "zfoo",
cmdtorun => "ls -la",
misc_data => [],
},
'zentara.zentara.net' => {
user => "zz",
password => "zbar",
cmdtorun => "/usr/bin/uptime",
misc_data => [],
},
);
foreach my $host (keys %hostdata) {
my $ssh = Net::SSH::Perl->new($host, port => 22); #, debug => 1 );
$ssh->login($hostdata{$host}{user},$hostdata{$host}{password} );
my ($out) = $ssh->cmd($hostdata{$host}{cmdtorun});
print "$out\n";
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]