I have just tried to modify the unbuffer - script which
comes with expect for use in a pipe, and I am stuck with
the result. My intent was to be able to do something like
make | unbuffer grep Error | ...
thereby avoiding the normal output buffering done by grep
when invoked in a pipe. The unbuffer - script solves the
buffering problem for programs which act as data source
only, but not for programs which receive their input via
stdin.
The unbuffer - script looks simple:
eval spawn -noecho $argv
set timeout -1
expect
My idea was to replace expect with interact in the last line,
because interact should connect stdin/stdout to stdin/stdout
of the spawned process.
But this "solution" seems to duplicate stdout:
echo 123 | unbuffer cat
yields
123
123
I am puzzled with this.
Can anybody explain this?
Does anybody have a solution for the "unbuffer in a pipe"-problem?
Many thanks in advance.
Dr.D.Ruppert
RTS GmbH
Schwieberdingen/Germany
r...@swb.scn.de
echo 123 | unbuffer cat
yields
123
123
Your script works fine for me. There were some interact bugs in early
versions of Expect. Perhaps you are running into one.
Don
In article <s6ahfy0...@muffin.nist.gov>,
li...@nist.gov (Don Libes) wrote:
> In article <3607BA...@swb.scn.de> Dieter Ruppert <r...@swb.scn.de> writes:
> I have just tried to modify the unbuffer - script which
> comes with expect for use in a pipe, and I am stuck with
> the result. My intent was to be able to do something like
>
> make | unbuffer grep Error | ...
>
> thereby avoiding the normal output buffering done by grep
> when invoked in a pipe. The unbuffer - script solves the
> buffering problem for programs which act as data source
> only, but not for programs which receive their input via
> stdin.
[snip]
> My idea was to replace expect with interact in the last line,
> because interact should connect stdin/stdout to stdin/stdout
> of the spawned process.
[snip]
>
> Your script works fine for me. There were some interact bugs in early
> versions of Expect. Perhaps you are running into one.
>
> Don
Uhh, could you define "early" a little more specifically? :)
I have access to 5.24 (which I would define as "reasonable but outdated") I
still seem to be having problems with getting it to work as advertised...
Perhaps my ignorance about what expect is really doing is the problem?
Any and all help would be GREATLY appreciated!
{tparker@cats7} % cat `which unbuf`
#!/usr/prod/contrib/bin/expect --
eval spawn -noecho $argv
set timeout -1
interact
{tparker@cats7} % cat t
Read -'say here'+
Read -'not me'+
Read -'exit here'+
{tparker@cats7} % cat t | unbuf grep here
Read -'say here'+
Read -'not me'+
Read -'exit here'+
{tparker@cats7} % uname
AIX
{tparker@cats7} % oslevel
4.1.5.0
{tparker@cats7} % expect -v
expect version 5.24.0
Tom P.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum