tmaly has asked for the wisdom of the Perl Monks concerning the following question:
I have a version of Expect 1.15 that I am attempting to use to capture input from commands such as ls -l
However, the input appears to be get chopped as I cannot see all of the files from the listing command. I have been logging the output and also checking the accumulator.
Upon inspection of the Expect module, it appears that it performs a sysread using a fixed number of bytes.
Are there any solutions to capture the full output of a command that might dump quite a bit of output to STDOUT?
Best Regards
Ty
Update:
I used the perl debugger to walk through Expect and then I came up with a solution that works
# given an Expect object in $e # given a command to run in $command # given a timeout value in $timeout # given that command does not print ENDOFCOMMAND to STDOUT $e->send("$command;echo ENDOFCOMMAND\n"); $e->expect($timeout,[qr/(?<!echo )ENDOFCOMMAND/ => sub { 0;}], [qr/(echo ENDOFCOMMAND)/ => sub { exp_continue;}]); $outputfromcommand = $e->before();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Expect Question
by elTriberium (Friar) on Jul 14, 2009 at 00:55 UTC | |
by tmaly (Monk) on Jul 14, 2009 at 13:58 UTC | |
by elTriberium (Friar) on Jul 14, 2009 at 18:03 UTC | |
|
Re: Expect Question
by Khen1950fx (Canon) on Jul 14, 2009 at 22:36 UTC |