A
A
Andrew2016-09-24 20:30:40
PHP
Andrew, 2016-09-24 20:30:40

How to get the text of a program error when accessing it through exec?

Hello!
Through php, I access one program through the exec function, in addition to the resulting response (data array), the program also writes an error text in the console if the command was not set correctly.
I get the answer itself through the second parameter $output, but the error text does not return and does not place it in the $output array.
Is there any way to read what kind of error the program generated?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Yankovsky, 2016-09-24
@ntzch

Add " 2>&1"
That would be something like this:

exec(' YOU_SHELL_COMMAND --arg=a --arg=b  2>&1', $out, $status);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question