diff --git a/bindings/phpdemo.php b/bindings/phpdemo.php new file mode 100644 index 000000000..a1eb33aa8 --- /dev/null +++ b/bindings/phpdemo.php @@ -0,0 +1,41 @@ + array("pipe", "r"), // stdin is a pipe that the child will read from + 1 => array("pipe", "w"), // stdout is a pipe that the child will write to + 2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to +); + +$cmd = "rigctl -m 2"; +$process = proc_open($cmd, $descriptorspec, $pipes); + +if (is_resource($process)) { + // $pipes now looks like this: + // 0 => writeable handle connected to child stdin + // 1 => readable handle connected to child stdout + // Any error output will be appended to /tmp/error-output.txt + + echo fread($pipes[1], 32); + + echo "Main Freq: "; + fwrite($pipes[0], "f Main\n"); + fread($pipes[1],32); + echo fread($pipes[1],64); + echo "\n"; + echo "=====\n"; + + fwrite($pipes[0], "f Sub\n"); + echo "Sub Freq:" ; + echo fread($pipes[1],32); + echo "\n"; + + fclose($pipes[0]); + fclose($pipes[1]); + + $return_value = proc_close($process); + + echo "command returned $return_value\n"; +} +?>