How do you call a c program from php?
Posted: Tue Aug 06, 2002 11:43 am
Ok, my problem is this - I need to call a c program from a php. I also need to pass a string to
it and have it return an array or string. I was thinking about calling it like its cgi script,
but I'm not to sure how to do that. I haven't figured the variable passing because I'm just
trying to get it to run first.
I tried -
passthru("./webetest 2>&1");
and the output is-
sh: ./webetest: Permission denied
I also tried -
$output3= `./webetest`;
echo "output3 :<pre>$output3</pre><br>";
The output is blank
Next I tried-
passthru("g++ webetest.c 2>&1");
And it produces -
In file included from webetest.c:28: FDXParser.h:43:23: warning: no newline at end of file
FDXParser.h:43:23: warning: no newline at end of file /usr/bin/ld: cannot open output file a.out:
Permission denied collect2: ld returned 1 exit status
I tried shell_exec(), system(), and exec() functions. None work. Does anyone know ho to do this?
Or does anyone have example code.
Thank you,
KW
it and have it return an array or string. I was thinking about calling it like its cgi script,
but I'm not to sure how to do that. I haven't figured the variable passing because I'm just
trying to get it to run first.
I tried -
passthru("./webetest 2>&1");
and the output is-
sh: ./webetest: Permission denied
I also tried -
$output3= `./webetest`;
echo "output3 :<pre>$output3</pre><br>";
The output is blank
Next I tried-
passthru("g++ webetest.c 2>&1");
And it produces -
In file included from webetest.c:28: FDXParser.h:43:23: warning: no newline at end of file
FDXParser.h:43:23: warning: no newline at end of file /usr/bin/ld: cannot open output file a.out:
Permission denied collect2: ld returned 1 exit status
I tried shell_exec(), system(), and exec() functions. None work. Does anyone know ho to do this?
Or does anyone have example code.
Thank you,
KW