[comp.sys.ibm.pc] Re-directing the output of commands in a BAT file

jai@im4u.UUCP (05/16/87)

Some time back there was a query about how to re-direct the output of 
every command in a BAT file to another file.  (I didn't save the
original article and can't find it in the news directory now - sorry.)

If the file is FOO.BAT then the command "foo > foo.out" does not
re-direct the output of the commands in foo.  To do that give the
command:

     command /c foo > foo.out

Now the original command processor spawns a child command processor
which runs FOO.BAT as its sole task and exits.  The original command
processor ensures that the output of the child command processor (and
all its children) are re-directed.  Note that the child command
processor (on DOS 3.1 at least) does not have as large an environment
as the original, so if the file FOO.BAT sets a lot of new environment
variables, it will run out of environment space.  Also this re-directs 
only standard output, not standard error: nothing from the DOS command
line can help re-direct standard error.

Jai.
-----------------
Jai Srinivasan, UUCP: {gatech,harvard,ihnp4,pyramid,seismo}!ut-sally!im4u!jai
ARPA:  		      jai@im4u.UTEXAS.EDU, jai@sally.UTEXAS.EDU

dick@zaphod.UUCP (Dick Flanagan) (05/19/87)

Summary:

Expires:

Sender:

Followup-To:


In article <1837@im4u.UUCP> jai@im4u.UUCP (Jai Srinivasan) writes:
>[...] nothing from the DOS command line can help re-direct standard error.

Polytron (the folks who bring you POLY-this-and-that) supply a program
with their PVCS and PolyMake products called RSE.  The syntax for RSE
is:  RSE <program name and parameters>.  This will redirect standard
error to standard out for the execution of <program name and parameters>.
(RSE stands for Redirect Standard Error).  An example they give of its
use is:  RSE MAKE -I > RESULTS.  This will run MAKE with errors being
ignored and all error and normal messages being redirected to the file
called RESULTS.  I've tried it and the puppy works!
-- 
Dick Flanagan, W6OLD
UUCP:  ...!ucbvax!sun!plx!dick
GEnie: FLANAGAN

madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) (05/19/87)

In article <632@zaphod.UUCP> dick@plx.UUCP (Dick Flanagan) writes:
>In article <1837@im4u.UUCP> jai@im4u.UUCP (Jai Srinivasan) writes:
>>[...] nothing from the DOS command line can help re-direct standard error.
>
>Polytron (the folks who bring you POLY-this-and-that) supply a program
>with their PVCS and PolyMake products called RSE.  The syntax for RSE
>is:  RSE <program name and parameters>.  This will redirect standard
>error to standard out for the execution of <program name and parameters>.
>(RSE stands for Redirect Standard Error).  An example they give of its
>use is:  RSE MAKE -I > RESULTS.  This will run MAKE with errors being
>ignored and all error and normal messages being redirected to the file
>called RESULTS.  I've tried it and the puppy works!

This would be a real quick program to make; merely put the stdout file
handle into the stderr file descriptor and invoke the program
specified on the command line.  I'd show you some code, but really I
haven't used MS-DOS file handles for anything and I'd probably screw
it up.  Someone want to do a quick-and-dirty RSE for the PD?

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          Jim Frost * The Madd Hacker | UUCP: ..!harvard!bu-cs!bucsb!madd
  H H                                 | ARPA:           madd@bucsb.bu.edu
H-C-C-OH <- heehee          +---------+----------------------------------
  H H                       | "We are strangers in a world we never made"

leder@ihlpm.UUCP (05/21/87)

In article <632@zaphod.UUCP>, dick@zaphod.UUCP (Dick Flanagan) writes:
> In article <1837@im4u.UUCP> jai@im4u.UUCP (Jai Srinivasan) writes:
> >[...] nothing from the DOS command line can help re-direct standard error.
> 
> Polytron (the folks who bring you POLY-this-and-that) supply a program
> with their PVCS and PolyMake products called RSE.  ....
> called RESULTS.  I've tried it and the puppy works!

Users of lsh can redirect stderr just like in un*x with:
	2> dest
	
Unfortunately, 2>&1 is not yet supported

Bob Leder