redirected output is buffered, how do you flush it?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Wed Feb 6 08:11:45 AEST 1991


In article <1991Feb05.000629.7401 at convex.com> tchrist at convex.COM (Tom Christiansen) writes:
> This is a general problem that comes up often, and I don't know any
> way of doing it unless you can get the program doing the writes to 
> flush its buffers now and then.

Here's a very easy general solution: Run % pty script > some_file
rather than % script > some_file. This will work for any program that
uses stdio normally. pty appeared in comp.sources.unix volume 23 and is
available via anonymous ftp to 128.122.128.22 in pub/hier/pty/*. It
works on most BSD systems. The original poster should check around at
gatech for a copy.

---Dan
Stupidity, n.: An overwhelming desire to rewrite one-line shell scripts
as 36-line Perl scripts so they run 6% faster. See Christiansen, Tommy.



More information about the Comp.unix.questions mailing list