Question

My first time to deploy matlab exec in php and i need ur help.

I have a matlab script compiled as sampleExe.exe (standalone app) with a single argument 'IdNo' to processes images. When i call it thru command line using sampleExe 2014000, the program runs and gives the desired output. However, I am having trouble when deploying/calling sampleExe.exe file from php as it gives me no output at all. :(

Here's the code i tried based on this: Call matlab exe from php is not working well

<?php
    define("EVAL_IMAGE","sampleExe.exe");
    $target=isset($_REQUEST['IdNo'])?trim($_REQUEST['IdNo']):"";
    if($target==""){
        echo "No folder name is passed";
      exit();
    }
    passthru(EVAL_IMAGE." ".$target);
?>

Any help is very much appreciated. Btw, I tried running it in a localhost and sampleExe.exe is also save in c:/wamp/www

Était-ce utile?

La solution

<?php
try {

  define("EVAL_IMAGE","mainProg1.exe");

  $target=isset($_REQUEST['IdNo'])?trim($_REQUEST['IdNo']):"";
  if($target==""){
    echo "No folder name is passed";
    exit();
  }

  set_time_limit(300);

  $return = exec(EVAL_IMAGE." ".$target);
  echo "return = " .$return;

}catch (Exception $e) { 
   echo 'Message: ' .$e->getMessage();
  }
  exit(0);  ?>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top