一个批处理文件,它的输出重定向已经重定向内从命令的输出? [英] Redirect output from a command within a batch file whose output is already redirected?

查看:1010
本文介绍了一个批处理文件,它的输出重定向已经重定向内从命令的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜查高有低,但是所有的建议和提示,我发现没有出于某种原因。我有一个被调用为这样一个批处理文件:

I've searched high and low, but all the suggestions and tips I've found do not work for some reason. I have a batch file that is being invoked as such:

cmd /C "automateMyProgram.bat >> automation.log 2>>&1"

这伟大工程:automation.log被加载的所有输出和错误为特定批处理文件。然而,批处理脚本中,我有以下命令:

That works great: automation.log gets loaded with all the stdout and stderr for that particular batch file. However, within that batch script I have the following command:

start php updateDB.php param1 param2 ^> updateDB.log

PHP脚本不会得到执行得很好,在参数就好读取,但updateDB.log永远不会创建。我保证PHP的错误在php.ini文件中报告设置为输出错误的命令行界面。有PHP脚本中的几个echo语句,我需要有记录到日志中,但它们不是出于某种原因输出。我读,如果你使用start命令调用的程序,您必须使用^操作符重定向输出,因为该程序是在一个新的进程开始了。我也试过:

The php script does get executed just fine and reads in the parameters just fine, but updateDB.log is never created. I ensured that php error reporting in the php.ini file is set to output errors to the command line interface. There are several echo statements within the php script that I need to have recorded to a log, but they are not being output for some reason. I read that if you use the start command to invoke a program, you must use the caret operator to redirect output since the program is started in a new process. I also tried:

start php updateDB.php param1 param2 >> updateDB.log

和那也不能工作。于是,我又试图:

and that didn't work either. So I then tried:

start /B "Database Update" "php" "param1" "param2" >> updateDB.log

而没有从批处理文件中工作,但它没有当我复制和直接粘贴入桌面上的一个cmd窗口。

and that didn't work from within the batch file, but it did when I copy and pasted it directly into a cmd window on the desktop.

任何可能你知道我可以重定向的PHP脚本的输出从批​​处理文件被调用?

Might any of you know how I can redirect the output of the php script being called from a batch file?

感谢您的时间和帮助!

推荐答案

这可能是最简单的解决方案:

This is probably the simplest solution:

start cmd /c "php updateDB.php param1 param2 > updateDB.log"

或者,如果你想在updateDB.log错误信息,

or, if you want to include error messages in updateDB.log,

start cmd /c "php updateDB.php param1 param2 > updateDB.log 2>&1"

这篇关于一个批处理文件,它的输出重定向已经重定向内从命令的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆