net::telnet Prompt and timeout issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SteveBark
    New Member
    • Feb 2007
    • 4

    net::telnet Prompt and timeout issue

    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).

    Code:
                    $telnet->cmd(String => "$level",
                            Prompt =>'/USER:$/');
                    $telnet->cmd(String => "$user",
                            Prompt => '/KEY:$/');
                    $connected = $telnet->cmd(String => "$pass",
                            Prompt => '/\?/',
                            Timeout => 60,
                            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
Working...