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?

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Amazing, I wasn't aware of stdout and stderr. That's fixed the issue. Thanks!
1

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

Try capturing stderr.

Hope this helps and good luck!

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.