($stdout,$stderr,$exit) = $ssh -> cmd ("apt-get install anjuta");
####
the output is:Reading Package Lists...
Building Dependency Tree...
The following NEW packages will be installed:
anjuta
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/2633kB of archives. After unpacking 6955kB will be used.
####
#!/usr/local/perl/bin/perl -w
use Term::ReadKey;
use Net::SSH::Perl;
use Net::SFTP;
my @machinelist = qw (
machine1.myip.com
machine2.myip.com
);
foreach my $machine (@machinelist) {
print "We are going to clobber $machine\n";
}
print "is this ok y/n? ";
my $input = ;
chomp $input;
if (!($input eq "y")) { die; }
print "what is your root password: ";
ReadMode ('noecho');
my $rootpw=;
chomp $rootpw;
ReadMode ('normal');
print "\n";
print "are you sure you want to continue y/n? ";
$input = ;
chomp $input;
if (!($input eq "y")) { die; }
foreach my $machine (@machinelist) {
my $status=0;
eval {
my $ssh = Net::SSH::Perl->new($machine,protocol=>2);
$ssh -> login ("root", $rootpw);
my ($stdout,$stderr,$exit) = $ssh -> cmd ("apt-get install anjuta");
#for debugging
print "the output is:$stdout\n";
$status=1;
}; if ($@) {
$status=0;
}
if ($status) {
print "$machine updated successfully.\n";
} else {
print "there was a failure updating $machine\n";
}
}