From fb9acd8b5eda50a0a89d3ac0f756f703317d48bc Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Sun, 13 Sep 2020 08:08:23 -0500 Subject: [PATCH] Adding phpdemo --- bindings/phpdemo.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 bindings/phpdemo.php 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"; +} +?>