Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-11-2006, 01:11 PM   #1
Registered: Oct 2003
Posts: 568

Rep: Reputation: 30
Undef handle weirdness in Net::SSH::Perl

Hey all. I have a bit of an odd problem. I am unable to connect using Net::SSH::Perl. It would seem that as soon as the new() sub is called, the handle to which the communication is assigned becomes undef. Here is the code:
#!/usr/bin/perl -w

use Net::SSH::Perl;

$ssh = Net::SSH::Perl->new('hostname');
$ssh->login('root','rootpass') || die;
($out, $err, $ext) = $ssh->cmd('date');
print "$out\n";
I was originally thinking that the entire SSH call was failing, however, by passing "debug=>1" to new(), it will echo progress to the command line:

sourcehostname: Reading configuration data /root/.ssh/config
sourcehostname: Reading configuration data /etc/ssh_config
sourcehostname: Allocated local port 1023.
sourcehostname: Connecting to hostname, port 22.
sourcehostname: Remote protocol version 2.0, remote software version OpenSSH_3.8.1p1
sourcehostname: Net::SSH::Perl Version 1.28, protocol version 2.0.
sourcehostname: No compat match: OpenSSH_3.8.1p1.
sourcehostname: Connection established.
Can't call method "login" on an undefined value at ./ line 19.
I attempted to print the $ssh var right after the new() call, and got the undef var error. What is going on here?

Also worth mentioning, is that usually the login() sub is called directly after new(). This is omitted here, as there is a key exchange. It should be noted, however, that an attempt to skip the use of login() results in the same "undefined value" error, only with the cmd sub instead of login.



Last edited by PenguinPwrdBox; 07-11-2006 at 01:31 PM.


perl, ssh

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the best way to parsing, handle files ksh, perl, c++ richikiki Programming 7 07-06-2006 08:18 AM
ssh -> perl -> spawn background proces hangs ssh session rhoekstra Programming 2 04-25-2006 01:05 AM
Perl File Handle Problem barkers Linux - Software 5 02-10-2006 08:00 AM
perl file handle Xris718 Programming 7 06-06-2005 02:34 PM
help with #ifdef #undef etc tuxfood Programming 3 06-29-2004 08:12 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:48 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration