Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Handle Telnet session fail errs/excute the next block of code?

Status
Not open for further replies.

max1x

Programmer
Jan 12, 2005
366
0
0
US
I am using Net::Telnet in my script.

my $t = new Net::Telnet (Timeout => 10);
$t->open("$host");
$t->login($uid, $passwd);
$t->cmd("chmod 700 $rmtDir/$putFile");
$t->cmd("$rmtDir$putFile");
sleep 10;

More code to parse the $putFile.
--------------------------------

Sometimes the telnet session times out, so the rest of the script does not execute, with an error on the command line stating that the session timed out. Is there a way to handle this error (i.e log it and skip it)and move on to execute the next block of code.

Thank you.

 
Got it, Thank you mbaranski... Just in case if any one is looking in the future:

eval {
$t->open("$HOST");
}; print $@; next if $@;

prints the error, but doe's not stop the rest of the code from executing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top