Available commands are: l - List all installed modules m - Select a module q - Quit the program cmd? l Installed modules are: Algorithm::C3 Algorithm::Diff App::cpanminus Archive::Tar Archive::Zip Authen::DecHpwd Authen::Passphrase B::Hooks::EndOfScope B::Utils CPAN CPAN::Meta CPAN::Meta::Check CPAN::Meta::Requirements CPAN::Meta::YAML Carp Carp::Clan Class::C3 Class::C3::XS Class::Inspector Class::Load Class::Load::XS Class::MethodMaker Class::Mix Compress::Raw::Bzip2 Compress::Raw::Zlib Crypt::DES Crypt::Eksblowfish Crypt::MySQL Crypt::PasswdMD5 Crypt::Rijndael Crypt::SSLeay Crypt::UnixCrypt_XS Cwd Data::Dump Data::Dumper Data::Entropy Data::Float Data::Integer Data::OptList Devel::GlobalDestruction Devel::GlobalDestruction::XS Devel::NYTProf Devel::StackTrace Devel::ptkdb Digest::CRC Digest::HMAC Digest::MD4 Digest::MD5 Digest::SHA Digest::SHA1 Dist::CheckConflicts Enbugger Encode Encode::Locale Eval::Closure Exporter ExtUtils::CBuilder ExtUtils::Config ExtUtils::Depends ExtUtils::Helpers ExtUtils::InstallPaths ExtUtils::MakeMaker ExtUtils::ParseXS File::HomeDir File::Listing File::Path File::Temp File::Which Getopt::Long HTML::Parser HTML::Tagset HTTP::Cookies HTTP::Daemon HTTP::Date HTTP::Lite HTTP::Message HTTP::Negotiate IO IO::Compress IO::HTML IO::Pipely IO::SessionData IO::Socket::SSL IO::Tty IO::Zlib IPC::Cmd IPC::Run IPC::Run3 JSON::Any LWP LWP::MediaTypes LWP::Protocol::https List::MoreUtils List::Util Locale::Maketext::Simple MRO::Compat Mail::Sendmail Module::Build Module::Build::Tiny Module::CoreList Module::Implementation Module::Load Module::Load::Conditional Module::Metadata Module::Runtime Module::Signature Moose MooseX::Types MooseX::Types::Path::Class Mozilla::CA Net Net::DNS Net::HTTP Net::ISC::DHCPd Net::SSH::Any Net::SSLeay NetAddr::IP POE POE::Filter::DHCPd::Lease POE::Test::Loops Package::DeprecationManager Package::Stash Package::Stash::XS Params::Check Params::Classify Params::Util Parse::CPAN::Meta Path::Class Perl Perl::OSType Pod Pod::Escapes Pod::Simple Probe::Perl SOAP::Lite Scalar::String Storable Sub::Exporter Sub::Exporter::Progressive Sub::Install Sub::Name Sub::Uplevel Task::Weaken Term::ReadKey Term::ReadLine Test::Deep Test::Differences Test::Exception Test::Fatal Test::Harness Test::NoWarnings Test::Requires Test::Script Test::Simple Test::Tester Test::Warnings Test::Without::Module Text::Diff Text::Glob Time::Local Try::Tiny URI UUID Variable::Magic WWW::RobotRules XML::LibXML XML::NamespaceSupport XML::SAX XML::SAX::Base XML::Simple YAML base namespace::autoclean namespace::clean parent cmd? #### 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}"; } } #### ./check_lib.pl 10 172.23.246.78 I am connected to 172.23.246.78 capture method failed: no backend available at ./check_lib.pl line 27. #### ################################################ 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 => "XX.XX.XX.XX", # for security reasons changed 10 => "YY.YY.YY.YY", # for security reasons changed 11 => "ZZ.ZZ.ZZ.ZZ", # for security reasons changed ); foreach my $lib ( sort keys %library ) { print "$lib $library{$lib}\n"; my $hostname = "$library{$lib}"; my $username = "root"; my $password = "XXXXXXXX"; # for security reasons changed my $cmd = "show library status"; 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}"; } } ################################################ > ./check_lib.pl 10 YY.YY.YY.YY Permission denied (publickey,password). I am connected to YY.YY.YY.YY capture method failed: unable to establish master SSH connection: bad password or master process exited unexpectedly at ./check_lib.pl line 27. ################################################ > ssh admin@YY.YY.YY.YY admin@YY.YY.YY.YY's password: Hello admin, welcome to the Command Line Interface for Quantum Scalar i6000 library: LTO0XX Type 'help' at the prompt for context-sensitive help. />show library status Component Status Description ------------------------ ------- ------------------------------------------------------------ System Health Orange Degraded Control Green Operational Connectivity Green Operational Power Green Operational Cooling Green Operational Robotics Green Operational Robotics Green Operational Robot Green Online Active Drives Yellow Warning; Active events: 4 Event: 458 Yellow Data cartridge L60368L6 has issued a Tape Alert 3 Event: 459 Yellow Data cartridge L60466L6 has issued a Tape Alert 3 Event: 460 Yellow Drive sled at [1,1,1,4,1,1] has issued a Tape Alert 37 Event: 462 Yellow Data cartridge C05155L3 has issued a Tape Alert 33 Drive# 1 (P1 D1) Green Online; Drive Empty Media Loads: 1941 - Read Errors: 50 - Write Errors: 1207 Read: 89266699MB - Written: 2254575167MB Drive# 2 (P1 D2) Green Online; Drive Empty Media Loads: 1160 - Read Errors: 83 - Write Errors: 571 Read: 205251608MB - Written: 736927492MB Drive# 3 (P1 D3) Green Online; Drive Mounted Media Loads: 700 - Read Errors: 46 - Write Errors: 360 Read: 103106456MB - Written: 473463422MB Drive# 4 (P1 D4) Yellow Online; Drive Mounted Media Loads: 285 - Read Errors: 5 - Write Errors: 31 Read: 21165341MB - Written: 65814048MB Drive# 5 (P1 D5) Green Online; Drive Mounted Media Loads: 1453 - Read Errors: 46 - Write Errors: 159 Read: 5449221MB - Written: 100007601MB Drive# 6 (P1 D6) Green Online; Drive Mounted Media Loads: 839 - Read Errors: 17 - Write Errors: 56 Read: 3844530MB - Written: 74439198MB Drive# 7 (P1 D7) Green Online; Drive Empty Media Loads: 657 - Read Errors: 10 - Write Errors: 59 Read: 4948358MB - Written: 42267420MB Drive# 8 (P1 D8) Green Online; Drive Empty Media Loads: 526 - Read Errors: 11 - Write Errors: 113 Read: 11475257MB - Written: 44659344MB Drive# 9 (P1 D9) Green Online; Drive Empty Media Loads: 4153 - Read Errors: 3040 - Write Errors: 7810 Read: 51868269MB - Written: 227092327MB Drive# 10 (P1 D10) Green Online; Drive Empty Media Loads: 3547 - Read Errors: 84 - Write Errors: 167 Read: 29919339MB - Written: 166894470MB Drive# 11 (P1 D11) Green Online; Drive Empty Media Loads: 3090 - Read Errors: 116 - Write Errors: 76 Read: 33787260MB - Written: 131713377MB Drive# 12 (P1 D12) Green Online; Drive Empty Media Loads: 812 - Read Errors: 6 - Write Errors: 14 Read: 6607257MB - Written: 15037428MB /> /> />exit Connection to YY.YY.YY.YY closed. $ #### ./check_lib.pl 10 172.23.246.78 I am connected to 172.23.246.78 Option not supported capture method failed: child exited with code 1 at ./check_lib.pl line 27. 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 => "172.23.246.7", 10 => "172.23.246.78", 11 => "172.23.246.79", ); foreach my $lib ( sort keys %library ) { print "$lib $library{$lib}\n"; my $hostname = "$library{$lib}"; my $username = "admin"; my $password = "XXXXXXXX"; my $cmd = "show library status"; 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}"; } } ./check_lib.pl 10 172.23.246.78 I am connected to 172.23.246.78 Option not supported capture method failed: child exited with code 1 at ./check_lib.pl line 27. > perl -d check_lib.pl Loading DB routines from perl5db.pl version 1.32 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(check_lib.pl:10): my %library = ( main::(check_lib.pl:11): 9 => "XX.XX.XX.XX", main::(check_lib.pl:12): 10 => "YY.YY.YY.YY", main::(check_lib.pl:13): 11 => "ZZ.ZZ.ZZ.ZZ", main::(check_lib.pl:14): ); DB<1> s main::(check_lib.pl:16): foreach my $lib ( sort keys %library ) { DB<1> s main::(check_lib.pl:18): print "$lib $library{$lib}\n"; DB<1> s 10 172.23.246.78 main::(check_lib.pl:19): my $hostname = "$library{$lib}"; DB<1> s main::(check_lib.pl:20): my $username = "admin"; DB<1> s main::(check_lib.pl:21): my $password = "XXXXXXXX"; DB<1> s main::(check_lib.pl:22): my $cmd = "show library status"; DB<1> main::(check_lib.pl:24): if ( my $ssh = Net::SSH::Any->new($hostname, user => $username, password => $password)) DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:21): 21: my $class = shift; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:22): 22: my %opts = (@_ & 1 ? (host => @_) : @_); DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:24): 24: my $target = delete $opts{host}; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:25): 25: defined $target or croak "mandatory parameter host missing"; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:27): 27: my ($user, $passwd, $ipv6, $host, $port) = 28: $target =~ m{^ 29: \s* # space 30: (?: 31: ([^\@:]+) # username 32: (?::(.*))? # : password 33: \@ # @ 34: )? 35: (?: # host 36: ( # IPv6... 37: \[$IPv6_re\] # [IPv6] 38: | # or 39: $IPv6_re # IPv6 40: ) 41: | # or 42: ([^\[\]\@:]+) # hostname / ipv4 43: ) 44: (?::([^\@:]+))? # port 45: \s* # space 46: $}ix or croak "bad host/target '$target' specification"; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:48): 48: ($host) = $ipv6 =~ /^\[?(.*)\]?$/ if defined $ipv6; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:50): 50: $user = delete $opts{user} unless defined $user; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:51): 51: $port = delete $opts{port} unless defined $port; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:52): 52: $passwd = delete $opts{passwd} unless defined $passwd; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:53): 53: $passwd = delete $opts{password} unless defined $passwd; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:54): 54: my ($key_path, $passphrase); DB<1> print $passwd XXXXXXXX DB<2> Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:55): 55: unless (defined $passwd) { DB<2> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:59): 59: my $timeout = delete $opts{timeout}; DB<2> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any.pm:60): 60: my $target_os = _first_defined delete $opts{target_os}, 'unix'; DB<2> s Net::SSH::Any::Util::_first_defined(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any/Util.pm:59): 59: sub _first_defined { defined && return $_ for @_; return } DB<2> print $target_os DB<3> s Net::SSH::Any::Util::_first_defined(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any/Util.pm:59): 59: sub _first_defined { defined && return $_ for @_; return } DB<3>