Hello fellow monks,
I am using the Expect module (v1.15) to automate a simple telnet process that logs in and sends a sample ping. Now I know I can probably use the Net::Telnet module, but I am using this for a purpose. Here is a snippet of my code (logtext is a simple function writing to a logfile).
while($perform_step > 0)
{
if ($tcp_transx_param{$row_ref->[$i]}{$perform_step})
{
logtext "Value of step is $perform_step";
logtext "Sending =>$tcp_transx_param{$row_ref->[$i]}{$perform_
+step}{send}<=";
$session->send("$tcp_transx_param{$row_ref->[$i]}{$perform_ste
+p}{send}\r");
$session->expect($expect_timeout, '-re', "$tcp_transx_param{$r
+ow_ref->[$i]}{$perform_step}{expect}") || warn "Did not match at step
+ $perform_step for CollectionID $row_ref->[$i]" . $session -> exp_err
+or();
logtext "Expecting =>$tcp_transx_param{$row_ref->[$i]}{$perfor
+m_step}{expect}<=";
if ($session->exp_error())
{
logtext "ERROR=>" . $session->exp_error();
logtext "Closing Session";
$session->hard_close();
last;
}
else { $perform_step++; }
}
else
{
$perform_step=0;
$session->soft_close();
last;
}
logtext "Increasing my step to $perform_step";
}
The issue I seem to be having is that the while loop continues regardless of the response. It works fine with the correct password but if I use the wrong password, then it continues and reports failure at the wrong step. Please help.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.