🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1663

Re: Output redirection

#1663
From: Dan Bernstein
Date: Mon, 29 Oct 1990 22:10
30 lines
1474 bytes
In article <2933@litchi.bbn.com> rsalz@bbn.com (Rich Salz) writes:
> In <15479@hydra.gatech.EDU> gt0178a@prism.gatech.EDU (Jim Burns) writes:
> >to Abhay B. Joshi's c code. Let's assume a situation where you don't have
> >the source code. How would you synchronize output only thru shell
> >mechanisms?
> script(1).
> No doubt PTY can also do it.

No doubt, since there's a ``script'' clone included in the pty package.
Copy enclosed. Note that this version allows teeing to multiple files
(because it uses tee) and gives you a utmp entry so that talk/mail/etc
work (because it uses pty).

The simplest answer to Jim's question is to run ``pty foo'' rather than
``foo''. stdio in foo will see a tty and line-buffer output accordingly.

---Dan

#!/bin/sh
# Public domain.
case "$@" in
"") extra=typescript ;;
"-a") extra=typescript ;;
"-i") extra=typescript ;;
"-a -i") extra=typescript ;;
esac
echo "Script started, teeing $@" "$extra"
( echo 'Script started on '`date`;
  pty -s "$SHELL";
  echo 'Script done on '`date` ) | tee "$@" "$extra"
Technical Details
Message-ID: <12588:Oct2922:10:5290@kramden.acf.nyu.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!rutgers!cmcl2!kramden.acf.nyu.edu!brnstnd
References: <3447@idunno.Princeton.EDU> <15479@hydra.gatech.EDU> <2933@litchi.bbn.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!rutgers!cmcl2!kramden.acf.nyu.edu!brnstnd
From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein)
Newsgroups: comp.unix.shell
Subject: Re: Output redirection
Message-ID: <12588:Oct2922:10:5290@kramden.acf.nyu.edu>
Date: 29 Oct 90 22:10:52 GMT
References: <3447@idunno.Princeton.EDU> <15479@hydra.gatech.EDU> <2933@litchi.bbn.com>
Organization: IR
Lines: 30