My script telnets a router & does a traceroute on the device & then returns the output $response to a webpage. However when doing a traceroute to non reachable destinations, the trace continually times out until the (cisco) default of 30 icmp echos is completed, see below:
GSR-HSD-GW2#traceroute 194.117.xx.xx
Type escape sequence to abort.
Tracing the route to 194.117.xx.xx
1 194.117.xx.x 0 msec 208 msec 0 msec
2 19x.xx.xx.x 200 msec 204 msec 12 msec
3 * * *
4 * * *
<snip>
30 * * *
GSR-HSD-GW2#
My waitfor(String=> in this example is GSR-HSD-GW2# - but I obviously don't want to wait the full 2-3 mins until the failed trace has run it's course before $response has completed & the output can be printed to the html page.
My question is: can the waitfor string in Net::Telnet be expanded to cater for more then one variable ie. GSR-HSD-GW2# |&| * * *
Or is there an easier way to to do this that my dumb ass can't think of? (make the $response quit if more then 3 *'s are encountered - what code to use to do this?)
Script excerpt:
use Net::Telnet();
my $t = new Net::Telnet;
$t->errmode("return"
$t->open($router{$location});
$t->login (Name => "$router_login{$location}", Password => "$router_pass{$location}", Prompt => '/\#|&|\>/', Timeout =>60);
$t->print("trace $trace"
($response)=$t->waitfor(String=> "$router_prompt{$location}", Timeout => 15);
@lines_trace=split(/\n/,$response);
GSR-HSD-GW2#traceroute 194.117.xx.xx
Type escape sequence to abort.
Tracing the route to 194.117.xx.xx
1 194.117.xx.x 0 msec 208 msec 0 msec
2 19x.xx.xx.x 200 msec 204 msec 12 msec
3 * * *
4 * * *
<snip>
30 * * *
GSR-HSD-GW2#
My waitfor(String=> in this example is GSR-HSD-GW2# - but I obviously don't want to wait the full 2-3 mins until the failed trace has run it's course before $response has completed & the output can be printed to the html page.
My question is: can the waitfor string in Net::Telnet be expanded to cater for more then one variable ie. GSR-HSD-GW2# |&| * * *
Or is there an easier way to to do this that my dumb ass can't think of? (make the $response quit if more then 3 *'s are encountered - what code to use to do this?)
Script excerpt:
use Net::Telnet();
my $t = new Net::Telnet;
$t->errmode("return"
$t->open($router{$location});
$t->login (Name => "$router_login{$location}", Password => "$router_pass{$location}", Prompt => '/\#|&|\>/', Timeout =>60);
$t->print("trace $trace"
($response)=$t->waitfor(String=> "$router_prompt{$location}", Timeout => 15);
@lines_trace=split(/\n/,$response);