Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 421
  • Last Modified:

Redirect screen outputs to a file

I have a batch file which I want to run on a periodic basis. The commands and programs in the batch file will print to the screen. Is there any way to redirect the screen outputs to a single file? I want the outputs to be appended to the file every time the batch file is run.

Thanks!
0
yongsing
Asked:
yongsing
  • 2
  • 2
1 Solution
 
schmieguCommented:
dir > dir.txt

creates a dir.txt with a listing of the directory you run it in

dir >> dir.txt appends the listing of the dir to dir.txt, if it exists or creates a new one, if not.

cmd1 1>success.txt 2>error.txt redirects normal output to success.txt, errors to errot.txt

For more information search Windows 2000 help for redirection.
0
 
yongsingAuthor Commented:
Instead of redirecting at each command, is there any way to specify, at the beginning of the batch file, to redirect all outputs from all commands to the file?

So instead of:
command1 >> output.txt
command2 >> output.txt
command3 >> output.txt

I have:
"Redirection Command"
command1
command2
command3
0
 
tflCommented:
not - sadly there is no built in utility that does this.

Each of the commands is built to write to stdio - and this can then be piped to another output using ">" or ">>".

Sorry.

I suppose you could write a wrapper for the command that did the redirection, but just putting in ">> file.txt" is probably quicker.

Thomas
0
 
schmieguCommented:
I once had a DOS utility, that captured command output (there were some commands that didn't work with standard redirection), but I have no idea, if there exists one to do this in NT.
0
 
yongsingAuthor Commented:
I'll accept this solution since it's the next best thing to what I wanted. Thanks for your helps, guys!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now