1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php 执行命令屏幕输出捕捉 在php执行linux命令时显示所有输出

php 执行命令屏幕输出捕捉 在php执行linux命令时显示所有输出

时间:2022-01-14 18:10:21

相关推荐

php 执行命令屏幕输出捕捉 在php执行linux命令时显示所有输出

为了方便,给测试地址做了git hook,可以参考之前的文章,利用git的hook自动部署代码。现在发现使用exec之类的命令无法获取到错误的输出,获取到的结果相对于直接在终端执行命令少了很多信息,这很不方便调试。

Updating 0430ef4..377d045

在终端则是

Updating 0430ef4..377d045

error: Your local changes to the following files would be overwritten by merge:

public/coding.php

Please, commit your changes or stash them before you can merge.

Aborting

下面这么多的错误信息都没了,没办法知道是因为什么卡住,开始以为PHP函数原因,后来google了一下,才发现是需要更改一下shell的错误输出重定向,使用如下即可

cd /home/wwwroot/*** && /usr/bin/git pull 2>&1

修改之后获取到的错误信息如下

error: Your local changes to the following files would be overwritten by merge: public/coding.php

Please, commit your changes or stash them before you can merge.

Aborting

Updating 0430ef4..fac8fed

正确的如下

From /****/****

4454adb..40ba1aa develop -> origin/develop

Updating 4454adb..40ba1aa

Fast-forward

readme.md | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

这样就很直观了

分享本文到:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。