home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / ibm / pc / programm / 568 < prev    next >
Encoding:
Internet Message Format  |  1992-11-10  |  3.9 KB

  1. Xref: sparky comp.sys.ibm.pc.programmer:568 comp.os.msdos.programmer:10496
  2. Path: sparky!uunet!news.tek.com!ogicse!decwrl!decwrl!public!heard
  3. From: heard@public.BTR.COM (Charles M. Heard  heard@btr.com)
  4. Newsgroups: comp.sys.ibm.pc.programmer,comp.os.msdos.programmer
  5. Subject: Re: Redirecting STDERR
  6. Summary: patch to command.com allows subsequent redirection
  7. Message-ID: <8293@public.BTR.COM>
  8. Date: 11 Nov 92 03:00:49 GMT
  9. Article-I.D.: public.8293
  10. References: <1992Nov05.042258.126673@zeus.calpoly.edu> <1992Nov9.151005.8011@informatik.uni-wuerzburg.de> <1d9g03INNq53@golem.wcc.govt.nz> <klosp.25.720972094@rimail.interlan.com>
  11. Followup-To: comp.sys.ibm.pc.programmer
  12. Organization: BTR Public Access UNIX, MtnView CA. For info contact: info@BTR.COM
  13. Lines: 100
  14.  
  15. In article <1992Nov9.151005.8011@informatik.uni-wuerzburg.de> schoof@dec5.informatik.uni-wuerzburg.dbp.de (Jochen "Joscho" Schoof) writes:
  16. >From article <1992Nov05.042258.126673@zeus.calpoly.edu>, by mwormley@zeus.calpoly.edu (Matt Wormley):
  17. >[some lines deleted]
  18. >> 
  19. >>    Doesn't >& work for redirecting both stdout and stderr?  I think that's
  20. >> it. 
  21. >> 
  22. >>     worm
  23. >
  24. >Sure it does, but only if you use a proper shell like 4DOS! 
  25. >- Jochen
  26.  
  27. Right.  In fact, command.com interprets the ampersand as the first character
  28. of the target file to which stdout is being redirected.  The following is what
  29. happens under DOS 3.3;  the same effect (with small variations in the
  30. dialogue) occurs in DOS 5.0.
  31.  
  32. B:\>if exist &nul del &nul
  33.  
  34. B:\>c:\dos\comp *.@@@ *.@@@ >&nul
  35.  
  36. Compare more files (Y/N)?
  37. B:\>dir
  38.  
  39.  Volume in drive B has no label
  40.  Directory of  B:\
  41.  
  42. BACKUPID @@@      128  11-07-92   9:43a
  43. ARTFORM  ZOO   356859  11-07-92   2:20a
  44. &NUL               85  11-08-92   3:04p
  45.         3 File(s)      3072 bytes free
  46.  
  47. B:\>type &nul
  48.  
  49. B:BACKUPID.@@@ and B:BACKUPID.@@@ 
  50.  
  51. Eof mark not found
  52.  
  53. Files compare ok
  54. n
  55.  
  56. One work-around for this particular piece of DOS brain-damage
  57. was presented in <klosp.25.720972094@rimail.interlan.com> by
  58. klosp@rimail.interlan.com (Patrick Klos), who writes:
  59.  
  60. >[some lines deleted]
  61. >
  62. >Here's a dirty little program that easily forces anything from STDERR to 
  63. >STDOUT.  Maybe this will do the trick for you!
  64. >
  65. >[followed by source code for a TSR which redirects all I/O from handle 2
  66. >(stderr) to handle 1 (stdout), also deleted]
  67.  
  68. Another way is to install a patch having the same effect in command.com.
  69. The following dialog does this to the DOS 5.0 command.com and saves the
  70. patched version to errout.com.  The same technique works for DOS 3.3
  71. provided that you make the necessary adjustments to the addresses.
  72.  
  73. C:\>debug command.com <errout.rsp
  74. -r
  75. AX=0000  BX=0000  CX=BAE5  DX=0000  SP=FFFE  BP=0000  SI=0000  DI=0000  
  76. DS=229A  ES=229A  SS=229A  CS=229A  IP=0100   NV UP EI PL NZ NA PO NC 
  77. 229A:0100 E95D14        JMP    1560                               
  78. -a bbe5
  79. 229A:BBE5 mov ax,4600       <---- function 46h = force duplicate handle
  80. 229A:BBE8 mov bx,0001       <---- open handle to be duplicated (stdout)
  81. 229A:BBEB mov cx,0002       <---- open handle to be redirected (stderr)
  82. 229A:BBEE int 21
  83. 229A:BBF0 jmp 1560
  84. 229A:BBF3 
  85. -a 0100
  86. 229A:0100 jmp bbe5
  87. 229A:0103 
  88. -rcx
  89. CX BAE5
  90. :bbf3
  91. -
  92. -n errout.com
  93. -w
  94. Writing 0BBF3 bytes
  95. -q
  96.  
  97.  
  98. One may now redirect stderr  and stdout from whatever program, batch file, or
  99. DOS internal command one wishes as follows:
  100.  
  101. C:\>errout /c -DOS-COMMAND-LINE- >OUTFILE
  102.  
  103. (other redirections i.e. >> and | also work).  Compared to Patrick Klos's
  104. TSR this generally uses more memory since it loads a secondary command 
  105. processor (although you have to do this anyway to redirect the output from
  106. a batch file), but it has the advantage of allowing the program or batch file
  107. which is invoked to redirect stdout to a file different from OUTFILE if it
  108. needs to.  I have used this technique under both DOS 3.3 and DOS 5.0 to
  109. redirect error messages from software library build scripts in which
  110. revision history information normally produced on stdout is redirected to
  111. a temporary file for subsequent processing.
  112.  
  113. C. M. Heard
  114. heard@btr.com
  115.