SUMMARY: unbuffer a output of a command, pty port on Solaris?

From: Michael Wang (
Date: Thu Oct 08 1998 - 09:15:28 CDT


  In short, how to unbuffer a output of a command?

  Some unix commands which uses stdio library is fully buffered (versus line
  buffered) when writing to a file which is a non-tty. This can be a problem
  because when you run
    command > log 2>&1
  and the command is hung and is killed, you will not get anything in the log
  file which you want to use for debugging purpose. The answer in the Unix
  FAQ is to use "pty" program, but I found the program is not ported to


  From: Casper Dik <casper@holland.Sun.COM>

  Use this one line C program:
  _isatty(int fd) { return 1;}
  /* Compile: cc -G isatty_preload.c -o -Kpic */
  /* Use: env LD_PRELOAD=/path/to/ a_common > log 2>&1 */

  From someone else:
  "expect" provides a three-line "unbuffer" program. Find "unbuffer" from
  the index of the expect book.


  I tried the following but found they do not work:

  command | tail
  mknod pipe p; command > pipe &; cat pipe
  command | while read i; do echo "$i"; done
  command 2>file 1>&2

  I very much like to find a native solution, i.e. no reference to
  /usr/local, but it does not seem to have one.

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:50 CDT