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();
In reply to Expect Question by tmaly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |