简体   繁体   English

批处理执行的日志输出问题

[英]Issue with logging output of batch execution

I have a file batchfile.bat that has some 7zip and Mysql operations. 我有一个具有一些7zip和Mysql操作的文件batchfile.bat I have a second batch file to execute this called executor.bat . 我还有第二个批处理文件来执行此命令,称为executor.bat The executor.bat file only has the below code executor.bat文件仅包含以下代码

.\batchfile.bat >>output.txt

So i expect all execution output to be written into output.txt . 因此,我希望所有执行输出都将写入到output.txt However, when i double click on executor.bat , i see the command prompt open and some mysql error messages, are coming on this command prompt instead of moving into the output.txt file. 但是,当我双击executor.bat ,我看到命令提示符打开,并且一些mysql错误消息出现在此命令提示符下,而不是移到output.txt文件中。 On the other hand, i can see 7-zip command line output getting captured in the output.txt file. 另一方面,我可以看到在output.txt文件中捕获了7-zip命令行输出。

How can i further redirect the messages on command prompt to go into the output.txt file 我如何进一步重定向命令提示符下的消息以进入output.txt文件

The >> redirector appends a STDOUT (text output) to the target file, but mysql error messages are sent to STDERR (error text output). >>重定向器将STDOUT (文本输出)附加到目标文件,但是mysql错误消息被发送到STDERR (错误文本输出)。 To redirect both output and errors to one file, use next syntax: 要将输出和错误都重定向到一个文件,请使用以下语法:

.\batchfile.bat >>output.txt 2>>&1

FYI, all numeric handles are: 仅供参考,所有数字句柄是:

STDIN     = 0  Keyboard input
STDOUT    = 1  Text output
STDERR    = 2  Error text output
UNDEFINED = 3-9

Error messages get sent to the command prompt through a different output pipe than regular messages. 错误消息通过与常规消息不同的输出管道发送到命令提示符。

Try updating executor.bat to .\\batchfile.bat >>output.txt 2>>output.txt 尝试将executor.bat更新为.\\batchfile.bat >>output.txt 2>>output.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM