Advanced shell scripting question :-)

Kevin D. Clark kclark at CetaceanNetworks.com
Thu Sep 5 14:08:37 EDT 2002


"Steven W. Orr" <steveo at syslang.net> writes:

> This is actually even closer to what I want. The problem is now strictly 
> that the output into both is not coming out in the same order as what 
> appears on the screen.

...

> It works great, except that the order is not being preserved. :-(

Actually, the order is being preserved -- I guarantee it.  If you put
stuff into a pipe in a certain order, I guarantee to you that this
stuff will come out the other side in the same order.

Your problem has to do with stdio buffering, the fact that the stdio
library does different things with this buffering when the output is
connected to a terminal versus something else (fully-buffered versus
line buffering), and the whim of the kernel and the scheduler.

Your original question never specified that you wanted this "ordering"
(this is a nebulous term in these circumstances) to be preserved.  Now
that you've placed this additional constraint on the problem, the
solution becomes a lot trickier.

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc





More information about the gnhlug-discuss mailing list