When I access “some” of the server\switch through the following code I am getting a message on the console “Press ENTER to start“. Since not all servers give this message, I am trying (without success so far) to capture this message, check if it include a word of ENTER and then send enter key to the consol because it stop at this point after it access the server successfully. Please help.
use Net::Telnet; $telnet = new Net::Telnet (Timeout => 10, Prompt => '/[%#>\"]\/] *$/'); $out='C:\Result.txt'; open OUT, ">>$out" or die "Cannot open $out for append :$!"; $telnet->open('11.123.123.123'); $telnet->login('user','user'); #-------------------------------- Here I am getting the console message “Press ENTER to start“ #-------------------------------- Then, I want to send enter to the console and here where I have the problem. #-------------------------------- $message=<STDIN>; if (/enter/i) #-------------------------------- @lines= $telnet->cmd(""); @lines= $telnet->cmd("ipmac"); print OUT @lines,"\n"; for ($X=0; $X <= $#lines; $X++) { @lines=$telnet->cmd(" "); print OUT @lines,"\n"; } close OUT; $telnet->close;
|