Great, that was my type mistake. New stucked at new error. It seems module not working with if target OS is not Unix / Linux. As in my case i am trying to run my command of one of the tape library.
./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. root@dc2cny - NON-PROD [/home/sbhamare/work/check_tape_library]> cat c +heck_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}, 'u +nix'; 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>

In reply to Re^6: Need help to implement Net::SSH::Any by mr.sagarbhamare
in thread Need help to implement Net::SSH::Any by mr.sagarbhamare

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.