Thread View: comp.sys.ibm.pc.programmer
7 messages
7 total messages
Started by dennis_c
Wed, 04 Nov 1992 21:40
Redirecting STDERR
Author: dennis_c
Date: Wed, 04 Nov 1992 21:40
Date: Wed, 04 Nov 1992 21:40
21 lines
1370 bytes
1370 bytes
I know this must have been asked 1000 times before, but I haven't been able to find the answer. I would appreciate it if someone can just point me to the relevant information. How can I redirect (or just suppress) output from a program that is going to stderr rather than stdout? I have a program (no source code) that insists on writing liberal amounts of information on what it's doing on the screen. Redirecting stdout only gets rid of some of the verbosity. I know stderr can be redirected if the program is called from within another program, but I don't want to do that because space is at a premium. Ideally, I need a command that I could use from a batch file before and after running the program that would send all stderr output to somewhere other than the screen. Any help will be much appreciated. Chris Dennis dennis_c@kosmos.wcc.govt.nz Wellington, New Zealand
Re: Redirecting STDERR
Author: Arthur Rubin
Date: Wed, 04 Nov 1992 23:52
Date: Wed, 04 Nov 1992 23:52
22 lines
1625 bytes
1625 bytes
In <1d9g03INNq53@golem.wcc.govt.nz> dennis_c@kosmos.wcc.govt.nz writes: >I know this must have been asked 1000 times before, but I haven't been >able to find the answer. I would appreciate it if someone can just >point me to the relevant information. >How can I redirect (or just suppress) output from a program that is >going to stderr rather than stdout? >I have a program (no source code) that insists on writing liberal >amounts of information on what it's doing on the screen. Redirecting >stdout only gets rid of some of the verbosity. I know stderr can be >redirected if the program is called from within another program, but >I don't want to do that because space is at a premium. Well, you can probably write a small ASM program which redirects stderr to NUL, and only use about 1/2 K of memory. -- Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal) My opinions are my own, and do not represent those of my employer. My interaction with our news system is unstable; please mail anything important.
Re: Redirecting STDERR
Author: Brian Cooper
Date: Thu, 05 Nov 1992 00:45
Date: Thu, 05 Nov 1992 00:45
19 lines
1255 bytes
1255 bytes
In article <1d9g03INNq53@golem.wcc.govt.nz> dennis_c@kosmos.wcc.govt.nz writes: >I know this must have been asked 1000 times before, but I haven't been >able to find the answer. I would appreciate it if someone can just >point me to the relevant information. > >How can I redirect (or just suppress) output from a program that is >going to stderr rather than stdout? > >Ideally, I need a command that I could use from a batch file before >and after running the program that would send all stderr output to >somewhere other than the screen. > How about putting 'ctty nul:' in front of the program invocation and 'ctty con:' afterwards? That ought to shut it up! -- Brian Cooper bcc@Eyring.COM Eyring Corp. +1 801-375-2434 or 1 800 YES PDOS
Re: Redirecting STDERR
Author: Matt Wormley
Date: Thu, 05 Nov 1992 04:22
Date: Thu, 05 Nov 1992 04:22
23 lines
1532 bytes
1532 bytes
In article <a_rubin.720921120@dn66> a_rubin@dsg4.dse.beckman.com (Arthur Rubin) writes:
>In <1d9g03INNq53@golem.wcc.govt.nz> dennis_c@kosmos.wcc.govt.nz writes:
>
>>I know this must have been asked 1000 times before, but I haven't been
>>able to find the answer. I would appreciate it if someone can just
>>point me to the relevant information.
>
>>How can I redirect (or just suppress) output from a program that is
>>going to stderr rather than stdout?
>
>>I have a program (no source code) that insists on writing liberal
>>amounts of information on what it's doing on the screen. Redirecting
>>stdout only gets rid of some of the verbosity. I know stderr can be
>>redirected if the program is called from within another program, but
>>I don't want to do that because space is at a premium.
>
>Well, you can probably write a small ASM program which redirects stderr to
>NUL, and only use about 1/2 K of memory.
Doesn't >& work for redirecting both stdout and stderr? I think that's
it.
worm
Re: Redirecting STDERR
Author: Patrick Klos
Date: Thu, 05 Nov 1992 14:01
Date: Thu, 05 Nov 1992 14:01
102 lines
3684 bytes
3684 bytes
In article <1d9g03INNq53@golem.wcc.govt.nz> dennis_c@kosmos.wcc.govt.nz writes:
>From: dennis_c@kosmos.wcc.govt.nz
>Subject: Redirecting STDERR
>Date: 4 Nov 1992 21:40:19 GMT
>I know this must have been asked 1000 times before, but I haven't been
>able to find the answer. I would appreciate it if someone can just
>point me to the relevant information.
>
>How can I redirect (or just suppress) output from a program that is
>going to stderr rather than stdout?
>
>I have a program (no source code) that insists on writing liberal
>amounts of information on what it's doing on the screen. Redirecting
>stdout only gets rid of some of the verbosity. I know stderr can be
>redirected if the program is called from within another program, but
>I don't want to do that because space is at a premium.
>
>Ideally, I need a command that I could use from a batch file before
>and after running the program that would send all stderr output to
>somewhere other than the screen.
>
>Any help will be much appreciated.
>
>Chris Dennis dennis_c@kosmos.wcc.govt.nz
>Wellington, New Zealand
Here's a dirty little program that easily forces anything from STDERR to
STDOUT. Maybe this will do the trick for you!
Page 56,132
Title FIXERR - Redirect STDERR to STDOUT
CODE Segment Public 'Code'
Assume CS:CODE,DS:CODE,ES:CODE,SS:CODE
Org 00100H
START Proc Near
Lea SP,STACK_TOP ;
Xor AX,AX ;
Mov ES,AX ;
Assume ES:Nothing
Cli ;
Mov AX,ES:[021H*4+0] ;
Mov Word Ptr OLD_INT21+0,AX ;
Mov AX,ES:[021H*4+2] ;
Mov Word Ptr OLD_INT21+2,AX ;
Mov AX,Offset CODE:INT21 ;
Mov ES:[021H*4+0],AX ;
Mov ES:[021H*4+2],CS ;
Sti ;
Mov AX,03100H ;T.S.R.
Lea DX,CODE_END+15 ;
Mov CL,4 ;
Shr DX,CL ;
Int 021H ;
START Endp
Assume CS:CODE,DS:Nothing,ES:Nothing,SS:Nothing
OLD_INT21 Dd 0 ;
INT21 Proc Far
Cmp AH,040H ;
Jne INT21z ;
Cmp BX,2 ;
Jne INT21z ;
Dec BX ;
INT21z: Jmp OLD_INT21 ;
INT21 Endp
Even
CODE_END Label Word
Dw 512 Dup (?) ;
STACK_TOP Label Word
CODE Ends
End START
Note that it's a .COM file. Build it like this:
masm fixerr;
link fixerr;
exe2bin fixerr.exe fixerr.com
Good luck!
========================================================================
Patrick Klos Internet: klosp@rimail.interlan.com
Klos Technologies, Inc. Compuserve: 71521,145
(603) 424-0138
========================All opinions are my own!========================
Re: Redirecting STDERR
Author: jim graham
Date: Sat, 07 Nov 1992 18:34
Date: Sat, 07 Nov 1992 18:34
19 lines
1314 bytes
1314 bytes
In article <1d9g03INNq53@golem.wcc.govt.nz> dennis_c@kosmos.wcc.govt.nz writes: >How can I redirect (or just suppress) output from a program that is >going to stderr rather than stdout? foo > foo.out redirects stdout only foo >& foo.out redirects stdout *AND* stderr hope this helps. :-) --jim -- #include <std_disclaimer.h> 73 DE N5IAL (/9) ------------------------------------------------------------------------------ INTERNET: jim@n5ial.chi.il.us | grahj@gagme.chi.il.us | j.graham@ieee.org ICBM: 41.70N 87.63W UUCP: gagme!n5ial!jim@clout.chi.il.us AMATEUR RADIO: n5ial@n9hsi (Chicago.IL.US.Earth) AMTOR SELCAL: NIAL ------------------------------------------------------------------------------
Re: Redirecting STDERR
Author: Charles M. Heard heard
Date: Wed, 11 Nov 1992 03:00
Date: Wed, 11 Nov 1992 03:00
100 lines
4073 bytes
4073 bytes
In article <1992Nov9.151005.8011@informatik.uni-wuerzburg.de> schoof@dec5.informatik.uni-wuerzburg.dbp.de (Jochen "Joscho" Schoof) writes:
>From article <1992Nov05.042258.126673@zeus.calpoly.edu>, by mwormley@zeus.calpoly.edu (Matt Wormley):
>[some lines deleted]
>>
>> Doesn't >& work for redirecting both stdout and stderr? I think that's
>> it.
>>
>> worm
>
>Sure it does, but only if you use a proper shell like 4DOS!
>- Jochen
Right. In fact, command.com interprets the ampersand as the first character
of the target file to which stdout is being redirected. The following is what
happens under DOS 3.3; the same effect (with small variations in the
dialogue) occurs in DOS 5.0.
B:\>if exist &nul del &nul
B:\>c:\dos\comp *.@@@ *.@@@ >&nul
Compare more files (Y/N)?
B:\>dir
Volume in drive B has no label
Directory of B:\
BACKUPID @@@ 128 11-07-92 9:43a
ARTFORM ZOO 356859 11-07-92 2:20a
&NUL 85 11-08-92 3:04p
3 File(s) 3072 bytes free
B:\>type &nul
B:BACKUPID.@@@ and B:BACKUPID.@@@
Eof mark not found
Files compare ok
n
One work-around for this particular piece of DOS brain-damage
was presented in <klosp.25.720972094@rimail.interlan.com> by
klosp@rimail.interlan.com (Patrick Klos), who writes:
>[some lines deleted]
>
>Here's a dirty little program that easily forces anything from STDERR to
>STDOUT. Maybe this will do the trick for you!
>
>[followed by source code for a TSR which redirects all I/O from handle 2
>(stderr) to handle 1 (stdout), also deleted]
Another way is to install a patch having the same effect in command.com.
The following dialog does this to the DOS 5.0 command.com and saves the
patched version to errout.com. The same technique works for DOS 3.3
provided that you make the necessary adjustments to the addresses.
C:\>debug command.com <errout.rsp
-r
AX=0000 BX=0000 CX=BAE5 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000
DS=229A ES=229A SS=229A CS=229A IP=0100 NV UP EI PL NZ NA PO NC
229A:0100 E95D14 JMP 1560
-a bbe5
229A:BBE5 mov ax,4600 <---- function 46h = force duplicate handle
229A:BBE8 mov bx,0001 <---- open handle to be duplicated (stdout)
229A:BBEB mov cx,0002 <---- open handle to be redirected (stderr)
229A:BBEE int 21
229A:BBF0 jmp 1560
229A:BBF3
-a 0100
229A:0100 jmp bbe5
229A:0103
-rcx
CX BAE5
:bbf3
-
-n errout.com
-w
Writing 0BBF3 bytes
-q
One may now redirect stderr and stdout from whatever program, batch file, or
DOS internal command one wishes as follows:
C:\>errout /c -DOS-COMMAND-LINE- >OUTFILE
(other redirections i.e. >> and | also work). Compared to Patrick Klos's
TSR this generally uses more memory since it loads a secondary command
processor (although you have to do this anyway to redirect the output from
a batch file), but it has the advantage of allowing the program or batch file
which is invoked to redirect stdout to a file different from OUTFILE if it
needs to. I have used this technique under both DOS 3.3 and DOS 5.0 to
redirect error messages from software library build scripts in which
revision history information normally produced on stdout is redirected to
a temporary file for subsequent processing.
C. M. Heard
heard@btr.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads