Reputation: 1416
I'm having trouble getting the full output from a shell command returned to a PHP script.
If i run this command in the terminal:
cd /home/moodledata; sh gam-create.sh "12345" "Test" "Mc Person"
Then I get the following as output in the terminal:
Creating account for [email protected]
Error 409: Entity already exists. - duplicate
However, if I run that through a PHP script:
<?php
$u = "Test";
$s = "Mc Person";
$u = "654321";
exec("cd /home/moodledata; sh gam-create.sh \"$u\" \"$f\" \"$s\"", $retval);
var_dump($retval);
I only get the following for the returned output:
array(1){
[0] => string(49) "Creating account for [email protected]"
}
I don't get the error message.
I've played around with using different functions, such as shell_exec() passthru() and system() but can't see to get this full output to be returned to the PHP script.
Could anyone advise as to where I'm going wrong?
Cheers.
Upvotes: 0
Views: 427
Reputation: 1416
Sorry, nevermind, I worked it out now. I needed to append 2>&1
to the command
Upvotes: 1