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

From: Michael Wang (mwang@tech.cicg.ml.com)
Date: Thu Oct 08 1998 - 09:15:28 CDT


Question:

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

  Explain:
  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
  Solaris.

Answers:

  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 isatty_preload.so -Kpic */
  /* Use: env LD_PRELOAD=/path/to/isatty_preload.so a_common > log 2>&1 */

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

Non-Answers:

  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