By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,835 Members | 2,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,835 IT Pros & Developers. It's quick & easy.

net::telnet Prompt and timeout issue

P: 4
Any pointers on this truly appreciated.

I am using net::telnet to connect to a modem pool and then connect with a remote piece of kit. Everything works fine normally, however on occassions the remote piece of kit may be busy and will not talk to me, leaving me to logoff cleanly and try again later.

Using net::telnet and the following code I am trying to wait for the prompt of ? to be returned if it is not returned after 60 seconds I wisk to run a sub that will basically log me off the device cleanly (failure to do so can leave the device port hung stopping further access until reset).

Expand|Select|Wrap|Line Numbers
  1.                 $telnet->cmd(String => "$level",
  2.                         Prompt =>'/USER:$/');
  3.                 $telnet->cmd(String => "$user",
  4.                         Prompt => '/KEY:$/');
  5.                 $connected = $telnet->cmd(String => "$pass",
  6.                         Prompt => '/\?/',
  7.                         Timeout => 60,
  8.                         Errmode => sub{&prompterr($params)} );
The issue is that the code jumps straight to the errmode rather than waiting for the prompt or the timeout!!!

Can anyone point me in the direction as to where I have gone wrong? Have I completely misunderstood how to use this?!?!

Best regards

Steve
Jul 18 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.