stan
06-21-1999, 07:44 PM
Hi,
In one of my PHP scripts I need to call a C program to do some of the (specialized) work. In the manual I read this could be done using the popen() function. An example would be:
<?
[nbsp][nbsp]$cmd = "program arguments";
[nbsp][nbsp]$fd = popen($cmd, "r");
[nbsp][nbsp]if (!$fd) {
[nbsp][nbsp][nbsp][nbsp]echo "Can't execute command $cmd
";
[nbsp][nbsp]}
[nbsp][nbsp]else {
[nbsp][nbsp][nbsp][nbsp]while ($buffer = fgets($fd, 4096)) {
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]echo $buffer."
";
[nbsp][nbsp][nbsp][nbsp]}
[nbsp][nbsp][nbsp][nbsp]$stat = pclose($fd);
[nbsp][nbsp][nbsp][nbsp]echo "Stat: $stat
";
[nbsp][nbsp]}
?>
My questions:
- Is this possible in the FQ sanatized environment?
- What should the path in $cmd be for a compiled C program in my directory on SIX.
I tried to test it with $cmd = "/bin/ls" but got no output (and exit code 256).
- Stan
In one of my PHP scripts I need to call a C program to do some of the (specialized) work. In the manual I read this could be done using the popen() function. An example would be:
<?
[nbsp][nbsp]$cmd = "program arguments";
[nbsp][nbsp]$fd = popen($cmd, "r");
[nbsp][nbsp]if (!$fd) {
[nbsp][nbsp][nbsp][nbsp]echo "Can't execute command $cmd
";
[nbsp][nbsp]}
[nbsp][nbsp]else {
[nbsp][nbsp][nbsp][nbsp]while ($buffer = fgets($fd, 4096)) {
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]echo $buffer."
";
[nbsp][nbsp][nbsp][nbsp]}
[nbsp][nbsp][nbsp][nbsp]$stat = pclose($fd);
[nbsp][nbsp][nbsp][nbsp]echo "Stat: $stat
";
[nbsp][nbsp]}
?>
My questions:
- Is this possible in the FQ sanatized environment?
- What should the path in $cmd be for a compiled C program in my directory on SIX.
I tried to test it with $cmd = "/bin/ls" but got no output (and exit code 256).
- Stan