You can use popen() to open the channel for the executable:
$fp = popen('./myexec.bin', 'w'); fwrite($fp, $data); pclose($fp);
Then, as suggested earlier, read from stdin in your C program:
fopen(stdin, "r");
It is popen() use popen() rather than exec('/bin/echo') , because you can write characters that are otherwise interpreted by the shell (&, |, ...). Note that the handle returned from PHP popen() must be closed with pclose() .
source share