1 This is a simple port of DJGPP's redir utility for those who're stuck with
2 braindead COMMAND/CMD shells on windows32 that cannot redirect standard
5 Here's the documentation provided with DJGPP's redir utility (also
6 provided in the .zip file):
10 DOS, in its many flavors and versions, lacks a decent I/O redirection
11 mechanism. Sure, it's got < and > and >>, but what about error
12 messages? Lots of people ask, "How do you send those error messages to
13 a file?" Well, you use a program like redir.
15 redir is basically a program that manipulates the standard file
16 descriptors by copying them, closing and opening them, etc. Once it
17 has the file descriptors where it wants them, it runs your program,
18 which inherits the changed descriptors. Thus, redir has nearly
19 complete control over the input and output of your program.
21 It also allows you to view the exit code of the program, and the
22 elapsed time of the program, by supplying the appropriate options on
25 Note that redir is built with command-line expansion and response
26 files disabled, so as to allow the application to control that
27 themselves. This means that you can't use those features to provide
28 redir's options or the command name, but if you use them for the
29 command's options, the command will do the expansion if it wants to.
31 The exit code of redir is 1 if it exits on its own accord, else it
32 returns the same error code as the program it runs.
34 Usage: redir [-i file] [-o file] [-oa file] [-e file] [-ea file] [-eo]
35 [-oe] [-x] command [args . . .]
37 Redirect stdandard input from file
39 Redirect standard output to file
41 Append standard output to file
43 Redirect standard error to file
45 Append standard error to file
47 Redirect standard error to standard output
49 Redirect standard output to standard error
51 Print the exit code of the command after it exits. If the exit
52 code is 0..255, it is printed as is. If it is not, the low byte
53 (0..255) is printed in decimal and the whole value is also
56 Options are processed in the order they are encountered. Thus, "-o foo
57 -eo" means "redirect output to foo, then redirect errors there also",
58 whereas "-eo -o foo" means "send errors to where output was going,
59 then move output to foo".
63 To redirect errors to a file:
64 redir -e errors.lst command ...
66 To redirect output to a file, and errors through a pipe:
67 redir -eo -o prog.out command ... | pipe