[The Question]
Is there some way to have the pipe/tee/write combo write lines immediately? ... if it can be done, what is the trade-off?
[The Backdrop]
My script sends a keypress to the terminal, which is running app.
That keypress causes app to write a marker to its log.
The log is the app's normal screen output (timestamped lines).
The log is being written via | tee -a log
The marker marks the line I want; ie. the timestamped line before the marker.
The problem is that when I then immediately search the log (using sed from the same script), it sometimes returns a previous marker, ie. the most recent marker has not been written to the log yet.
I assume this is a buffering issue, but I'm in unknown territory with that.
Not sure if it matters: The script is elisp. The terminal is emacs terminal emulator with a bash shell.
stdbufisn't in my Ubuntu 10.04 repository... I'll look further into it tomorrow... +1 for now... – Peter.O Dec 10 '11 at 17:26appwithout running it in the terminal... In this case I can't do that, becauseappismplayer, and I would lose the ability to control it via its interactive response to key-presses.However, I've found a temporary(?) workaround..
Each marker is unique, and because mplayer is constantly feeding the log, the buffer is flushed at a constant rate, so the problem occurs only for a short log (a long log takes longer to search). I've simply added a loop to repeat the search until the correct marker turns up. – Peter.O Dec 11 '11 at 05:16