Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by perl514 (Pilgrim)
on Nov 06, 2012 at 18:56 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-19 15:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found