[英]Running 'git pull' using shell_exec in PHP not displaying error
我正在为用PHP编写的github创建部署脚本。 我正在使用shell_exec
命令运行git pull
,效果很好。
拉动发生错误时会发生我的问题。 如果在终端中执行此操作,则会收到完整错误。 例如:
git pull origin master
Updating f706749..8468d24
test.txt: needs update
error: Entry 'test.txt' not uptodate. Cannot merge.
但是当我在shell_exec
运行相同的命令时,输出将被截断为
Updating f706749..8468d24
test.txt: needs update
错误消息被切断,可能是因为它是前一个响应的响应。 有没有办法返回完整的输出?
10-1缺少的行不是写到stdout而是写到stderr 。
在这种情况下,您可以使用以下命令将stderr重定向到stdout
"command 2>&1"
2>&1将错误消息重定向到普通输出文件。
将错误通过管道传递到您的输出。 在exec命令中使用2>,这是“标准错误”流。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.