Php shell_exec run spark identify

Hi,

I’m trying run spark identify inside a php code but the command don’t return nothing.

I realized that php does not wait for the command response
I’m using this script inside a php file

The core is connected using USB door and flashing blue.
When I try using command line, works fine.

<?
    $test= shell_exec('spark identify');
    echo $test;
?>

What is the problem?

I don’t have my cores active right now to test with, but maybe the output is going to stderr instead of stdout? If you’re on a Mac or Linux, try:

$test= shell_exec('spark identify 2>&1');

See if that captures the output.

If you’re in Windows, it’s more complicated…

$test = shell_exec("spark identify 2> output");
echo $test ? $test : join("", file("output"));

This will actually direct the output into a file named ‘output’, then capture the contents into the $test variable. Ugly.