[Discuss] bash output buffering
Edward Ned Harvey
blu at nedharvey.com
Tue Jun 19 12:03:49 EDT 2012
> From: discuss-bounces+blu=nedharvey.com at blu.org [mailto:discuss-
> bounces+blu=nedharvey.com at blu.org] On Behalf Of Edward Ned Harvey
>
> > Can you be more specific about what you exact commands you are using?
> > When I put the following into a file called foo:
> >
> > ===
> >
> > #!/bin/sh
> >
> > ping 127.0.0.1 > $HOME/xxx
> >
> > ===
> >
> > and then run
> >
> > "at -f foo now"
> >
> > The "tail -f $HOME/xxx" does exactly what you want (one line every
> second).
>
> Huh. Maybe the difference is /bin/bash versus /bin/sh
> ... Cuz ...
> That's exactly what I'm doing.
Now that I'm revisiting, and exploring *precisely* how the commands get
called (fed directly into at/cron, versus a script getting fed into at/cron,
and considering bash vs sh, etc) ... The root cause was sed.
I was actually doing ping 2>&1 | sed 'a;kdsjf;asjk' >> outputfile
When I check the manpage for sed, I discover the -u option for unbuffered,
and the problem is fixed. :-)
Thank you, Bill and others, for your help... I don't think I would have dug
into sed if I hadn't heard of a success story doing seemingly the same thing
elsewhere...
More information about the Discuss
mailing list