Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Unable to store the command output from Net::SSH2. Please help.

by perl514 (Pilgrim)
on Nov 06, 2012 at 18:56 UTC ( #1002559=note: print w/ replies, xml ) Need Help??


in reply to Unable to store the command output from Net::SSH2. Please help.

Hi

Tried using the Net::SSH::Any module, but it's not doing what I expected. I am going wrong somewhere.

I am trying to ssh into the VMWare Guest OS (CentOS 6.2). Before trying the script, I pinged and ensured that its working. I am also able to putty into the VMWare Guest OS, but not able to use the script for some reason.

Given below is the script

#!/usr/bin/perl use Modern::Perl; use Net::SSH::Any; my $host = '192.168.247.101'; my $user = "perl514"; my $passwd = "redhat"; my $ssh = Net::SSH::Any->new ($host, user => $user, password => $passw +d); my @output = $ssh->capture2("ls -l"); say "@output";

And here is the output. The cursor blinks for a while so it appears that it could be running the command, but returns the following error

Use of uninitialized value $output[0] in join or string at anyping.pl +line 10.

Basically I want to capture the output of the ls -l command in the @output.

Perlpetually Indebted To PerlMonks


Comment on Re: Unable to store the command output from Net::SSH2. Please help.
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-11-26 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (162 votes), past polls