Reputation: 466
First, I have a website in local with Wamp64. And I would like to execute a .exe file.
So I use the exec()
function like this :
$output = exec("cd 'C:\Program Files (x86)\ENENSYS\DiviSuite' & DiviSuite-CLI.exe --in-rf --in-rf-standars T --in-rf-frequency=474 --in-rf-bandwidth=8 --in-rf-duration=20 --out-file C:\wamp64\capture.ts");
The program has to record a stream and put it in C:\wamp64\ but it doesn't whereas when I execute the same command line in the MS DOS console it works.
Also, when I do an echo of $output the echo display nothing.
Thanks in advance.
Upvotes: 2
Views: 366
Reputation: 1385
Try this instead :
$output = exec("\"C:\\Program Files (x86)\\ENENSYS\\DiviSuite DiviSuite-CLI.exe --in-rf --in-rf-standars T --in-rf-frequency=474 --in-rf-bandwidth=8 --in-rf-duration=20 --out-file C:\\wamp64\\capture.ts");
It should work :)
Upvotes: 1
Reputation: 21493
try this
(function(){
if(($olddir=getcwd())===false){
throw new RuntimeException('getcwd() failed!');
}
if(!chdir('C:/Program Files (x86)/ENENSYS/DiviSuite')){
throw new RuntimeException('failed to enter DiviSuite folder!');
}
$output=array();
$ret=0;
exec('DiviSuite-CLI.exe --in-rf --in-rf-standars T --in-rf-frequency=474 --in-rf-bandwidth=8 --in-rf-duration=20 --out-file C:\wamp64\capture.ts',$output,$ret);
if($ret!==0){
echo "WARNING, DID NOT RETURN 0. THIS IMPLY AN ERROR IN MOST PROGRAMS.".PHP_EOL;
}
var_dump('returned:',$ret,'output:',$output);
chdir($olddir);
})();
Upvotes: 0
Reputation: 298
Can manually cd into DiviSuite folder and try to run that php file from DiviSuite folder , removing cd command from exec. ?
Upvotes: 0
Reputation: 409
Maybe it's better to use shell_exec
in this case because you are executing multiple commands.
doc: http://php.net/manual/function.shell-exec.php
Upvotes: 1