Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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.


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 = ''; 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 +line 10.

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

Perlpetually Indebted To PerlMonks

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2016-10-25 07:13 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (315 votes). Check out past polls.