开发者

Windows command to capture what's writing

Is there a Windows command that captures what's writing in the con开发者_StackOverflow社区sole window and write it to a text file?


Additionally, you may want to pipe error output to a file as well. By defualt error output is secondary and isn't logged to the > or >> location. To direct the secondary output to the primary output, add 2>&1 to the end of the line. I.E.:type %ROOTDIR%temp.txt | find /I "test" > %OUT% 2>&1


Do you just need to redirect the output of one command? If so, you can use:

my_command >output_file


You can pipe the output of any DOS command into a file using > or >>

Exmaple

dir > files.txt

Sends the output of dir into the files.txt overwriting the file if it already exists

dir >> files.txt

Appends the output of dir to files.text


To capture DOS stdout and stderr, you need to redirect both to the file that you are going to use for capturing your output.

For example:

C:>dir > dirTest.txt 2>&1

|____________||__|
  section 1    section 2

Section 1 redirects stdout to the file dirTest.txt, where section 2 redirects stderr to stdout. Microsoft has a good page that explains how you can redirect input and output here:

http://technet.microsoft.com/en-us/library/bb490982.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜