LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 08-10-2004, 02:43 AM   #1
mosh
LQ Newbie
 
Registered: Jun 2004
Posts: 10

Rep: Reputation: 0
Net::Telnet question on perl.


Hi All,
Pls. need your help.

I'm using Net::Telnet module on perl inorder to make a telnet connection to device:

...
$telnet= new Net::Telnet(Host=>5.1.1.11,Port=>9000,Timeout=>10);
...

Now, if the Net::telnet succeeded, it's great, but if it failed the script dies after timeout of 10 seconds, and I would like the perl script to go on after this T.O.
Anyone have an idea how to do it, while displaying an error message ilke FAIL to the screen ?

Thanks a lot,
Mush.
 
Old 08-10-2004, 04:32 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
try :

$telnet= new Net::Telnet(Host=>"5.1.1.11", Port=>"9000",Timeout=>10, Errmode =>"return");

$msg = $telnet->errmsg();
if( $msg ) { print "$msg\n"; }
 
Old 08-10-2004, 07:49 AM   #3
mosh
LQ Newbie
 
Registered: Jun 2004
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks !

I tried it, and when it supposed to fail, the error that displayed was "Can't call method "errmsg" on an undefined value".

Note that, when the Net-Telnet should success, the previous message didn't appear.
What is the problem ?
 
Old 08-10-2004, 09:43 AM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Try :

$telnet= new Net::Telnet(Port=>"9000",Timeout=>10, Errmode =>"return");
$telnet->open("5.1.1.11");

$msg = $telnet->errmsg();
if( $msg ) { print "$msg\n"; }
 
  


Reply



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
how do i install net-Telnet Whiteghost Linux - General 1 10-10-2005 10:27 AM
Using Perl NET::TELNET module DannyM Linux - Networking 4 02-15-2005 11:31 AM
perl and Net::FTP question Tomasfuego Programming 0 12-17-2003 08:13 AM
Help with perl and telnet Miky Programming 2 10-02-2003 04:17 AM
Net::Telnet mrPhantastik Programming 5 09-10-2003 02:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration