Problems calling an executable file inside a driver in laravel

1

I'm trying to call an executable .exe (a location is added in the PATH of WINDOWS ) within a controller in Laravel using the methods escapeshellarg and exec of the next Form:

$escaped_cmd = escapeshellarg('C:\wamp64\www\proyecto\app\Http\Controllers\openalpr_64\alpr.exe samples\us-4.jpg');
$salida=exec($escaped_cmd);
return $salida;

and it does not give me anything back. When I print the variable $escaped_cmd it returns exactly the same as it is being entered and I paste it directly to CMD I get this correctly.

C:^\wamp64^\www^\proyecto^\app^\Http^\Controllers^\openalpr_64^\alpr.exe samples^\us-4.jpg
plate0: 10 results
    - LTM378     confidence: 89.5721
    - LM378      confidence: 83.0723
    - LTM37B     confidence: 81.7983
    - LTH378     confidence: 76.4686
    - LTN378     confidence: 76.053
    - LM37B      confidence: 75.2985
    - LH378      confidence: 69.9688
    - LN378      confidence: 69.5532
    - LTH37B     confidence: 68.6948
    - LTN37B     confidence: 68.2792

Also, the exec() method works very well, since it correctly returns the exec('ipconfig') ; and the exec('echo hola mundo');

Much less returns error by browser console. What can it be?

    
asked by CESAR NICOLINI RIVER 12.06.2017 в 02:13
source

1 answer

1

Exec can receive 3 parameters, if only the first one exec () returns the last line of the results of the command.

string exec ( string $command [, array &$output [, int &$return_var ]] )

It would be something like this:

$escaped_cmd = escapeshellarg('C:\wamp64\www\proyecto\app\Http\Controllers\openalpr_64\alpr.exe samples\us-4.jpg');
$salida = array();
exec($escaped_cmd, $salida);
return $salida;
    
answered by 12.06.2017 в 09:57