Xref: utzoo comp.sys.ncr:288 comp.unix.questions:22051 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!uunet!ncrlnk!ncrstp!mercer From: mercer@ncrstp.StPaul.NCR.COM (Dan Mercer) Newsgroups: comp.sys.ncr,comp.unix.questions Subject: Re: Odd vi behaviour inside a shell script. Keywords: vi, sh, stderr, shell scripts Message-ID: <438@ncrstp.StPaul.NCR.COM> Date: 7 May 90 16:40:56 GMT References: <1284@telsys.aut.UUCP> Reply-To: mercer@ncrstp.StPaul.NCR.COM (Dan Mercer) Organization: St. Paul Lines: 42 In article <1284@telsys.aut.UUCP> jsmithso@aut.UUCP (Jim Smithson) writes: : :Here's a small problem I can't really explain. :I am running /bin/sh on my NCR Tower 32/650 under Sys V rel 2.01. : :Consider a shell script called foo.sh which contains the following two lines: : :vi foofile :not_a_command # here to give some error output : :I want to run this shell script and capture the output (stdout and stderr) :to a logfile, I also want to see the output as it happens. : :So I enter the command: foo.sh 2>&1 |tee foo.log :But this totally hoses up `vi`. `vi` runs fine if I enter: foo.sh |tee foo.log :But stderr is not written to the logfile. Same with: foo.sh | tee foo.log 2>&1 :`vi` also runs fine if I enter: foo.sh 2>&1 : :Can anybody explain what the problem is? :Can anybody suggest something that will work? : :Thanks in advance! :-- :James R. Smithson Ascom Autelca AG CH-3073 Guemligen/Switzerland :E-mail: jsmithso@aut.UUCP FAX: +41 31 527 745 Voice : +41 31 529 214 :UUCP: ...!uunet!mcsun!chx400!hslrswi!aut!jsmithso Vi uses stderr on the ioctl call that sets it up for raw data handling. If stderr is redirected, the terminal will not be in the correct state, and all the full screen algorithms will be off. I know of no way around this. However, ex works quite well with stdout and stderr redirected, since it does not use raw mode (you exit insert mode by typing a standalone period and an enter). When I wanted capture my macro mappings for a seminar I was giving on vi, that's what I did. -- Dan Mercer Reply-To: mercer@ncrstp.StPaul.NCR.COM (Dan Mercer)