i want run php script calls executable cpp file on remote server.
i have tried below:
1.created cpp file
// function example #include <iostream> using namespace std; int addition (int a, int b) { int r; r=a+b; return r; } int main () { int z; z = addition (5,3); cout << "the result " << z; return z; } generated .exe file , put in server's folder(test.exe)
step2 : created php scripts call exe file using 'shell_exec'
<?php if (function_exists('shell_exec')){ echo "enabled"; } else { echo "disabled"; } $file = 'test.exe'; if (!file_exists($file)) echo 'file not exists'; $out= shell_exec($file); //exec($file, $out); echo 'ouput is:: ' .$out;?> also, i've put php file on remote server , tried call php script in browser. shows error warning: shell_exec() [function.shell-exec]: unable execute 'test.exe'. want echo "ouput is:: 8".
please verify.
use:
exec("./test.exe", $out); note $out hold output.
remember thatshell_exec returns of output stream string, exec returns last line of output.
Comments
Post a Comment