in reply to Re: Catching timeout for Net::Telnet
in thread Catching timeout for Net::Telnet

It did not work the way I used it...it still just dies.
Any more ideas...
heres the modified code..
    use Net::Telnet (); 
 eval {
    $t = Net::Telnet ->new(Timeout => 10,
			  Prompt => '/.*# $/');
};
warn $@ if $@;    
$t->open("10.0.0.$num") || die "can't telnet to $num\n";
    $t->login('$log','$pwd');
    $t->cmd("cd /home/dir");

    @lines = $t->cmd("ps uax");
...
Thanks. HeffaK
  • Comment on Re: Re: Catching timeout for Net::Telnet

Replies are listed 'Best First'.
Re: Re: Re: Catching timeout for Net::Telnet
by no_slogan (Deacon) on May 09, 2001 at 23:00 UTC
    Go back and re-read my original post. You need to move all the operations on $t inside the eval {}. It's probably the open or login that's die()ing, not the Net::Telnet->new, anyway.

    If there's a failure at some point, you probably want to give up on the entire telnet session. After all, if the login fails, what's the chance of "cd /home/dir" working? If you put everything in the eval {}, the first one that dies will jump to the end of the eval block, skipping over the other commands.

      That did it... :) Thank you and Thank you again. HeffaK