阅读从PHP的exec混帐推的输出()函数 [英] Reading output of git push from PHP exec() function

查看:87
本文介绍了阅读从PHP的exec混帐推的输出()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写我的框架的命令行工具部署命令。它使用git的部署。

I'm writing a deployment command for my framework's command line tool. It uses git to deploy.

我有一个行,其中我这样做:

I have a line where I do this:

exec("git push {$remote} {$branch}:{$branch}", $shell_output, $status);

我想有推放在 $ shell_output 的输出,但它不是发生(输出只是显示了在终端)。我想是因为混帐是一个外部程序,因此创建一个新的输出流?

I would like to have the output of the push inside $shell_output, but its not happening (The output just shows up on terminal). I think because git is an external program and therefore creates a new output stream?

我使用上述输出缓冲器<一试href=\"http://stackoverflow.com/questions/5461175/php-command-line-output-buffer-outputs-regardless-of-buffer-settings\">here无济于事。我敢肯定,在孤单SO东西,可以回答这个问题,但一直没能找到它后,挖得多..

I've tried using an output buffer described here to no avail. I'm sure theres something on SO that can answer this, but haven't been able to find it after much digging..

因此​​,任何帮助将非常AP preciated:)

So any help will be much appreciated :)

推荐答案

git的将其输出发送到STDERR不是STDOUT,所以你需要重定向的东西是这样的:

git sends its output to STDERR not STDOUT so you will need to redirect that with something like this:

混帐推REPO --progress 2 - ;&放大器; 1

或文件:

混帐推REPO --progress&GT; /路径/到/文件2 - ;&放大器; 1

这篇关于阅读从PHP的exec混帐推的输出()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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