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"); }], ); }
In reply to Perl's Expect - foreach loop by tc1364
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |