[CALUG] More I/O buffering foolishness
Chris Edillon
jce at zot.com
Wed Mar 1 20:21:28 CST 2006
On Wed, 2006-03-01 at 09:43 -0500, Jason C. Miller wrote:
> I've asked a buffering question on here before and have now run into a
> similar-yet-different issue and was wondering if anyone had any insight.
>
> Here's the short story...
>
>
> At the command line (bash) ...
> -----------------------------------
> (cd /blah ; tar cvf - * 2>/dev/null) | (cd /blah2 ; tar xvf - 2>/tmp/log) | \
> perl -e 'while (<STDIN>) { print }'
> -----------------------------------
> ... works fine. All it does is print the stdout from the tar extraction.
>
perhaps i'm missing something, but why pipe the output
to perl? it's already printing to stdout.
> The oddness is that, inside the script ...
> -----------------------------------
> (cd /blah ; tar cvf - * 2>/dev/null) | (cd /blah2 ; tar xvf - 2>/tmp/log)
> -----------------------------------
> ... will line-buffer just fine. It's when I try to pipe that into
> anything else AFTER that the buffering issues come up. I've tried it with
> both perl and awk and they both do the same thing. I tried forcing the
> flush in the perl, but that doesn't do anything and I really don't know if
> that's the issue or not.
>
like mark, i can't recreate this either. i wrote this little snippit
and it doesn't seem to buffer the output (with or without the perl bit):
#!/bin/sh
tar -cvf - /usr/share/doc/* 2>/dev/null | (cd /tmp/test && tar -xvf -
2>/tmp/testlog) | perl -pe ''
if this is input for Xdialog, perhaps it is buffering before
printing anything?
chris
More information about the lug
mailing list