From: Scotty74 <_si...@ya...> - 2007-04-24 19:37:46
|
I've got a program that ssh's into a storage array and issues a query to get some information about devices. The command executes and displays some number of lines, and then depending on the number of device either gives back a prompt '# ' after displaying the devices, or prompts the user to hit a key with the following string: 'Press any key to continue (Q to quit)' I am never able to successfully match on the 'Press any key to continue (Q to quit)'... I never make it into that sub routine, and eventually fail. the log file shows a '^@ at the end of the Press any key string, I'm not sure why, but tried to match on it. Any suggestions would be appreciated. Thanks. here's a snippet: $ssh_exp->send("$command"); $ssh_exp->debug(3); $ssh_exp->expect( $GLOBAL_TIMEOUT , [ qr/Press any key to continue \(Q to quit\)\^\@$/ => sub { print("Got a press any key to continue\n"); my $fh = shift; #$ssh_exp->send("N"); $fh->send("BITEME\r"); exp_continue; } ] , [ '# $', sub { print("Got a prompt back\n"); } ] ); print("Sleeping\n"); sleep(5); here is the output which is logged to a file: # show disks encl Status Encl Slot Vendor Model Serial# Size(GB) ------------------------------------------------------------------------------ Up 0 0 ATA HDS725050KLA360 KRVN65ZAJAUR1F 500 Up 0 1 ATA HDS725050KLA360 KRVN65ZAJAY5HF 500 Up 0 2 ATA HDS725050KLA360 KRVN65ZAJAUSLF 500 Up 0 3 ATA HDS725050KLA360 KRVN65ZAJAV1LF 500 Up 0 4 ATA HDS725050KLA360 KRVN65ZAJAUUNF 500 Up 0 5 ATA HDS725050KLA360 KRVN65ZAJ9RH6F 500 Up 0 6 ATA HDS725050KLA360 KRVN65ZAJAV6YF 500 Up 0 7 ATA HDS725050KLA360 KRVN65ZAJAUUEF 500 Up 0 8 ATA HDS725050KLA360 KRVN65ZAJAT3ZF 500 Up 0 9 ATA HDS725050KLA360 KRVN65ZAJASBEF 500 Up 0 10 ATA HDS725050KLA360 KRVN65ZAJAV09F 500 Up 0 11 ATA HDS725050KLA360 KRVN65ZAJAY1WF 500 Up 1 0 ATA HDS725050KLA360 KRVN65ZAJARLWF 500 Up 1 1 ATA HDS725050KLA360 KRVN65ZAJAY06F 500 Up 1 2 ATA HDS725050KLA360 KRVN65ZAJAT8HF 500 Up 1 3 ATA HDS725050KLA360 KRVN65ZAJAY3DF 500 Up 1 4 ATA HDS725050KLA360 KRVN65ZAJAT04F 500 Up 1 5 ATA HDS725050KLA360 KRVN65ZAJAV4HF 500 Up 1 6 ATA HDS725050KLA360 KRVN65ZAJAT20F 500 Up 1 7 ATA HDS725050KLA360 KRVN65ZAJAY2HF 500 Up 1 8 ATA HDS725050KLA360 KRVN65ZAJASHXF 500 Press any key to continue (Q to quit)^@ -- View this message in context: http://www.nabble.com/problem-with-expect-pattern-match-tf3640813.html#a10168043 Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |