Path: 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 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"