Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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

Replies are listed 'Best First'.
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...


Re: Perl ssh error
by salva (Abbot) 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.
Re: Perl ssh error
by keszler (Priest) 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. $

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://930529]
Approved by keszler
[ambrus]: Yes, I was explaining him why I believe it's impossible.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-12-12 13:20 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (332 votes). Check out past polls.