Skip Menu |
 

This queue is for tickets about the Expect CPAN distribution.

Report information
The Basics
Id: 62359
Status: resolved
Priority: 0/
Queue: Expect

People
Owner: Nobody in particular
Requestors: freddycardozo15 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: Expect Output issue
Download (untitled) / with headers
text/plain 722b
I am trying to clear the contents of the accumulator and then execute the command and then capture the contents of the command via the expect log file. I am getting the output of the previous accumalator contents even after clearing them Code. $expect_handle->send("1st Command to be executed"); $expect_handle->clear_accum(); $expect_handle->log_file(undef); $expect_handle->log_file("expect_output_file","w"); $expect_handle->send("2nd Command to be executed"); $expect_handle->expect(undef,"prompt"); $output = `cat expect_output_file`; $output contains the output of the previous command ( e.g 1st command ) instead of the output of the 2nd command . I need $output to contain only the output of the 2nd command.
Download (untitled) / with headers
text/plain 1.2k
On Fri Oct 22 01:00:15 2010, freddycardozo wrote: Show quoted text
> I am trying to clear the contents of the accumulator and then execute > the command and then capture the contents of the command via > the expect log file. I am getting the output of the previous accumalator > contents even after clearing them > > Code. > $expect_handle->send("1st Command to be executed"); > $expect_handle->clear_accum(); > $expect_handle->log_file(undef); > $expect_handle->log_file("expect_output_file","w"); > $expect_handle->send("2nd Command to be executed"); > $expect_handle->expect(undef,"prompt"); > >
Show quoted text
> $output = `cat expect_output_file`; > > $output contains the output of the previous command ( e.g 1st command ) > instead of the output of the 2nd command . > > I need $output to contain only the output of the 2nd command.
I don't think this can ever work. The accum does not have the data yet when clear_accum is called so it could not clear it. In order this to work one needs to call $expect_handle->expect($timeout, 'something else'); before calling clear_accum with a large enough $timeout to allow the AUT to send output. See the test here: https://github.com/szabgab/expect.pm/blob/master/t/03-log.t I think this can be closed as "Not bug"


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.