Hello,
I am using php 4.3.0, and am trying to launch the command line interface for cisco network registrar, and be able to send commands to it and read the output from those commands. Problem I am having is that the commands can take some time to actually respond with output. I can make it work by putting in a sleep after the write/before the read, but i'd like to not have to do that. I have pasted some sample code below (which is basically made up of sample's from the proc_open samples on the php site).
Any suggestions would be appreciated.


   $dspec = array
    (
     0 => array("pipe", "r"),
     1 => array("pipe", "w"),
     2 => array("file", "/tmp/ErrorLog.txt", "a"),
    );

$process = proc_open("$cli", $dspec, $pipes);

   if (is_resource($process))
    {
     fwrite($pipes[0], $str."\n");

stream_set_blocking($pipes[1], FALSE);

     while ($ret = fgets($pipes[1], 1024))
      {
       print $ret . "\n";
      }
    }

   fclose($pipes[0]);
   fclose($pipes[1]);

$return_value=proc_close($process);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to