tc1364 has asked for the wisdom of the Perl Monks concerning the following question:
foreach table $tables { set timeout 3600 expect { ">" { sleep 1; send "TABLE $table; FORMAT 132 PACK\r" } timeout { errmsg "TABLE COMMAND PROMPT NOT FOUND FOR $table" } } expect { "COMMAND DISALLOWED DURING DUMP" { errmsg "TABLE: $table - DUM +P IN PROGR ESS" } "Directory is full" { errmsg "TABLE: $table - DIRECTORY IS FUL +L" } "UNKNOWN TABLE" { sleep 1; send "abort\r"; continue } "TABLE: $table" { send "" } timeout { errmsg "TABLE NAME NOT FOUND FOR $table" } } expect { "The first column" { sleep 1; send "LIS ALL\r" } timeout { errmsg "FIRST COLUMN NOT FOUND FOR $table" } } expect { "EMPTY TABLE" { sleep 1; continue } "TOP" { send "" } timeout { errmsg "TOP NOT FOUND FOR $table" } } expect { "BOTTOM" { sleep 1; send "quit all\r" } timeout { errmsg "BOTTOM NOT FOUND FOR $table" } } }
@tables = ("TONES", "OFCENG", "EASAC"); foreach $table (@tables) { $exp->expect(180, [ qr/>/i, sub { my $self = shift; sleep(1); $self->send("TABLE $table; FORMAT 132 PACK\r"); }], [ qr/UNKNOWN TABLE/i, sub { my $self = shift; sleep(1); $self->send("")ort\r"); next; }], [ qr/TABLE: $table/i, sub { my $self = shift; $self->send(""); }], [ qr/The first column/i, sub { my $self = shift; sleep(1); $self->send("LIS ALL\r"); }], [ qr/EMPTY TABLE/i, sub { my $self = shift; sleep(1); next; }], [ qr/TOP/i, sub { my $self = shift; $self->send(""); }], [ qr/BOTTOM/i, sub { my $self = shift; sleep(1); $self->send("quit all\r"); }], ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl's Expect - foreach loop
by Roy Johnson (Monsignor) on Apr 28, 2005 at 17:58 UTC | |
by tc1364 (Beadle) on Apr 28, 2005 at 18:22 UTC | |
by Roy Johnson (Monsignor) on Apr 28, 2005 at 18:27 UTC | |
by tc1364 (Beadle) on Apr 28, 2005 at 18:49 UTC | |
by tc1364 (Beadle) on Apr 28, 2005 at 18:51 UTC |