# I/O redirection in XP batch cmd processor



## jerardfjay (May 19, 2005)

I have a need to capture the output of a command to a file in a XP batch script

This can be achieved fairly easy with the following syntax

command >file_name or
command 1>file_name

However, this will redirect all of the output from the standard_output (console/screen) to the file called file_name.

How can I get output from the command on to the screen as well as capture/send the same to a file using native XP cmd processor commands?

Any suggestions/ideas/hints are greatly appreciated. 
Thanks
:4-dontkno


----------



## ricer333 (Sep 17, 2004)

Okay,
So you want the batch file to run/execute whatever command it is (maybe run a particular file or something?) then you want that output pumped to the stdout (screen) as well as pumping it to a file?

If this is correct, I don't know if you can do that all at the same time.

What I would do, is in your batch file, first have the line that pumps the output to the stdout (screen). Then, follow that up on the next line that pumps the output to the file.

e.g.
line1: command (executes & sends to stdout)
line2: command > file_name (executes & sends to file_name)

Now, these will execute in succession, so note that if your command/program is time sensitive, then the data maybe different!

Hope this helps!


----------

