smurray has asked for the wisdom of the Perl Monks concerning the following question:
--------------------code below --------------------------- # Power switch on sub # This will connect to a network power switch and apply power to the u +ut # Author: # Date: 6/2/04 # Rev: 01 sub NetSwitchOn { print <<EOB; Turning on the UUT.... ;-) EOB $telnet = Net::Telnet->new( Host => $PS2, Port => 23, Prompt => '/[$%#>] $/', Errmode => sub {&errorHandler()}, Input_log => $pwr_log, Dump_log => $dumpPW_log, ) or "return"; print "Connected to Power Switch: ", $PS2, "\n"; print "-" x 40, "\n"; $telnet->print ('/on 1'); ok ($telnet->waitfor('/Processing - please wait/'), "Turning on th +e power switch"); ok ($telnet->waitfor('/Complete/'), "Unit is on"); $telnet->print ('/x'); $telnet->close; print "Connection closed: ;-( \n "; print "-" x 40, "\n"; } #--------------------------------------------------------------------- +--------# # This routine will handle the telnet object errors. #--------------------------------------------------------------------- +--------# sub errorHandler { print "Another system must be connected..\n"; print "Will retry in 5 seconds..\n"; sleep 5; redo; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: net::telnet errmode issue
by tachyon (Chancellor) on Jul 27, 2004 at 02:52 UTC |