Problem: When using Expect.pm, fatal errors generated by the program being
executed do not seem distinguishable from other output by the program.
Here is a pruned example to demonstrate the problem:
my $object = Expect->spawn("program"); # 1
my $error = ($object->expect(30, 'password:'))[1]; # 2
die "$error\n" if ($error); # 3
print $object "incorrectpassword\r"; # 4
$object->soft_close(); # 5
An error in line 2 caused by a problem with the expect command will go
to STDERR. An error generated by 'program'--such as will be generated
after sending the incorrect password at line 4--will go to STDOUT, not
STDERR, which is also where any data resulting from a valid run of 'program'
will go.
Is there some way I can separate the output of 'program' based upon the
status of 'program'? If there is any mention of such behavior in the
Expect docs then it was probably in the section that was too dense for
me, so please elaborate instead of pointing me to them, as I have read
quite a few times.
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.