doqau82086 2011-06-22 22:33
浏览 481
已采纳

在PHP中使用shell_exec运行'git pull'不显示错误

I'm creating a deployment script for github, written in PHP. I'm using the shell_execcommand to run git pull which works fine.

My issue occurs when there is an error with the pull. If I do it in Terminal, I get the full error. For example:

git pull origin master
Updating f706749..8468d24
test.txt: needs update
error: Entry 'test.txt' not uptodate. Cannot merge.

But when I run the same command in shell_exec the output is truncated to just

Updating f706749..8468d24
test.txt: needs update

The error message is getting cut off, possibly because it's a response from the previous response. Is there a way to return the full output?

  • 写回答

3条回答 默认 最新

  • dongxuan58311366668 2011-06-22 22:38
    关注

    10-1 the missing lines are not written to stdout but to stderr.

    In that case you can redirect the stderr to stdout with

    "command    2>&1"
    

    The 2>&1 redirects the error messages to the normal output file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置