Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Net::SSH::Any does not return output for few specific commands

by salva (Abbot)
on Apr 02, 2013 at 16:28 UTC ( #1026733=note: print w/ replies, xml ) Need Help??


in reply to Net::SSH::Any does not return output for few specific commands

Add error checks:

$ssh = Net::SSH::Any->new($hostname, user => $username, password => $p +assword); $ssh->error and die "unable to connect to remote host: " . $ssh->error +; $out = $ssh->capture(“who am I”); $ssh->error and die "remote command failed: " . $ssh->error; print $out;


Comment on Re: Net::SSH::Any does not return output for few specific commands
Download Code
Replies are listed 'Best First'.
Re^2: Net::SSH::Any does not return output for few specific commands
by magic_007 (Initiate) on Apr 02, 2013 at 16:35 UTC

    Thanks Salva for quick reply. I added error check but no break. The code is connecting to the host it did not die and the $ssh->error is printing 0.

      My problem got solved. Instead of "who am i" I used "whoami" and i got the output.

      I even tried "who -am -u" but it did not work but i could not find out why capture doesn't return output for those commands.

      Thanks anyways.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026733]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2015-07-07 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls