Perl-Sensitive Sunglasses | |
PerlMonks |
How can I show all input and output with Expect.pmby GeorgeAdams (Initiate) |
on Oct 06, 2014 at 21:17 UTC ( [id://1103014]=perlquestion: print w/replies, xml ) | Need Help?? |
GeorgeAdams has asked for the wisdom of the Perl Monks concerning the following question: Here is a little Perl server script. It displays (1), accepts a line of input, then displays (2), etc. If you type "error" or "commit", it gives a custom message. If you type "exit", it quits. Otherwise, it just endlessly takes lines of input.
Now, here is an Expect.pm client script to interact with the server script by typing in various lines.
What I want is to be able to store the entire session from start to finish, including everything the server script generated, and everything the Expect.pm script sent. It should look like this: (1) This is the first command (2) Here is the second command (3) error Error on command #3 (4) commit Committing data (5) This is the last command (6) exit Exiting program... But the STDOUT display that comes from running the client script looks like this: This is the first command (1) (2) Here is the second command error (3) Error on command #3 (4) commit This is the last command Committing data (5) (6) exit Exiting program... and the file specified by $exp->log_file (tmp/expect.out) shows this: (1) (2) (3) Error on command #3 (4) Committing data (5) (6) Exiting program... I've tried experimenting by logging various combinations of the command itself + the before_match and after_match variables returned by $exp->expect(). But so far I haven't gotten the right combination. And it seems like an awfully clunky way to get what I'm looking for. So, what's the best practice for capturing the entirety of an Expect.pm session? Thanks to anyone who can help!
Back to
Seekers of Perl Wisdom
|
|