Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!sdd.hp.com!hp-col!hpldola!hp-lsd!jimr From: jimr@hp-lsd.COS.HP.COM (Jim Rogers) Newsgroups: comp.unix.shell Subject: Re: I/O Redirection question Message-ID: <27620010@hp-lsd.COS.HP.COM> Date: 16 Apr 91 19:10:04 GMT References: <1991Apr11.144844.28800@riacs.edu> Organization: HP Logic Systems Division - Col Lines: 59 David W. Smith writes: I have a question regarding I/O redirection. I have a program in which writes to stdout and stderr. I have redirected both of these to a file. Now comes the problem. I need to capture stdout in a file along with stderr, but I also need stdout to go to the terminal for prompting of input. Is this possible? If so, how does one do this? Answers may be mailed to me directly or you may post responses. A solution in for the csh, sh, ksh are all acceptable. Thank you, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ David W. Smith NASA Ames Research Center All comments are my own and (415) 604-6555 do not reflect NASA opinions Internet: dwsmith@ames.arc.nasa.gov or policies. USPS: M/S 233-3 Moffett Field, CA 94035-1000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------- The following modest example should show you how to do it. Note that both stderr and stdout are sent to a file and to the screen together. This should make the program fully interactive. #!/bin/ksh a_process() { # select writes to stderr select action in "First Action" "Second Action" "Terminate Actions" do if [ -z "$action" ] then # write error message to stderr print 2 "Unknown action\nPress return to continue" else #write responses to stdout case ${REPLY} in 1 | 2) print "${action}";; 3) print "Bye...";exit;; esac fi done } a_process 2>&1 | tee /dev/tty >> foobar Jim Rogers Hewlett-Packard Company Colorado Springs, Colorado