LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 07-11-2006, 01:11 PM   #1
PenguinPwrdBox
Member
 
Registered: Oct 2003
Location: /illinois/chicago
Distribution: Slackware/Gentoo/FC/RHEL
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:
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:

Code:
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 ./sshtest.pl 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.

TIA!

-ppb

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


Reply

Tags
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


All times are GMT -5. The time now is 08:56 AM.

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