1

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?

adamturtle
  • 57
  • 1
  • 9

3 Answers3

7

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.

Peter Tillemans
  • 34,983
  • 11
  • 83
  • 114
1

By searching a bit, I might have found the answer to your problem.

Try capturing stderr.

Hope this helps and good luck!

Community
  • 1
  • 1
Jeff Gortmaker
  • 4,607
  • 3
  • 22
  • 29
0

Pipe the error to your output. In the exec command use 2> which is the "standard error" stream.

Steve Nguyen
  • 5,854
  • 5
  • 21
  • 39