Advertisement

03.19.2008 at 11:59PM PDT, ID: 23256124
[x]
Attachment Details

Error Mode

Asked by mawingho in Perl Programming Language

I have a Perl program, how can I make a subroutine to run whenever an error or timeout is occurred?

Suppose one of the statement is timed-out, when it is happened, it should only call mytimeout() function and NOT perform the rest of the program.

How to do that?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
sub connect_bridge{
	$t = new Net::Telnet (Timeout => 40, Errmode=>'die',Input_log => $input_log);
	$t->open($bridge_ip) or die ("Cannot connect to $noc_host!\n");
 
	print "Start Logging in to $bridge_ip.........";
 
	$t->waitfor($bridge_login_prompt);
	$t->print($bridge_username);
 
	$t->waitfor($bridge_password_prompt);
	$t->print($bridge_password);
 
	$t->waitfor($bridge_prompt);
 
	print "Success!\n\n";
}
[+][-]03.20.2008 at 12:15AM PDT, ID: 21168851

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.20.2008 at 12:28AM PDT, ID: 21168890

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628