Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
The stupid question is the question not asked
 
PerlMonks  

Perl ssh error

by Anonymous Monk
on Oct 10, 2011 at 04:08 UTC ( #930529=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

use Net::SSH::Perl; use strict(); my $host = ""; my $user = ""; my $password = ""; #-- set up a new connection my $ssh = Net::SSH::Perl->new($host,debug=>1,use_pty=>1); #-- authenticate $ssh->login($user, $pass); #-- execute the command my($stdout, $stderr, $exit) = $ssh->cmd("ls -l /home/$user");
Error ----- Name "main::pass" used only once: possible typo at Untitled2 line 17. Can't locate object method "new" via package "Net::SSH::Perl" (perhaps + you forgot to load "Net::SSH::Perl"?) at Untitled2 line 15.
How to solve this error

Comment on Perl ssh error
Select or Download Code
Re: Perl ssh error
by armstd (Friar) on Oct 10, 2011 at 04:36 UTC

    You really need to learn to format this better, in HTML form it makes no sense. How do I post a question effectively?

    One tip though, you're mixing $pass and $password, and the strict error is pretty clear about it being related to $pass...

    --Dave

Re: Perl ssh error
by keszler (Curate) on Oct 10, 2011 at 05:21 UTC

    Net::SSH::Perl's new method is documented as Net::SSH::Perl->new($host, %params). Try

    my $ssh = Net::SSH::Perl->new($host, debug=>1, use_pty=>1 ); #-- authenticate $ssh->login($user, $password);

    update - never mind, 'view source' let me see that the new appears to be OK.

    Your use strict(); is wrong, that may be part of your problem.

    $ perl -lE' > use strict(); > say $x; > ' $ perl -lE' use strict; say $x; ' Global symbol "$x" requires explicit package name at -e line 3. Execution of -e aborted due to compilation errors. $
Re: Perl ssh error
by salva (Monsignor) on Oct 10, 2011 at 08:08 UTC
    Besides the use strict() error noted by keszler that also reveals a $pass/$password missmatch, it seems that your installation of Net::SSH::Perl is broken.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2013-05-24 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (493 votes), past polls