cat check_lib.pl #!/usr/local/bin/perl #Check tape library status # use strict; use warnings; use Net::SSH::Any; use v5.10; my %library = ( 9 => "pwxs1", 10 => "pwxs2", 11 => "pwxs3", ); foreach my $lib ( sort keys %library ) { print "$lib $library{$lib}\n"; my $hostname = "$library{$lib}"; my $username = "root"; my $password = "XXXX"; #Change for this example my $cmd = "ls -l"; if ( my $ssh = Net::SSH::Any->new($hostname, user => $username, password => $password)) { print "I am connected to $hostname \n"; my @out = $ssh->capture($cmd); $ssh->error and die "capture method failed: " . $ssh->error; say "Below is the output: \n"; say "@out"; } else { print "I am not able to connect $library{$lib}"; } }