#!/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"; } }