Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] bash output buffering



> 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...




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org