Re: Writing to process STDIN and reading its STDOUT from PHP4?
| From: | Steve Hsieh | Date: | Sat, 23 Sep 2000 22:11:08 +0000 |
| Subject: | Re: Writing to process STDIN and reading its STDOUT from PHP4? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17334@lists.php.net to get a copy of this message | ||
Thanks Robert,
However, those functions deal with PHP's own stdin/stdout. What I am trying
to do is write to STDIN of a process started by PHP and then read the
process STDOUT.
So far, the only way I know how to do this is to first stick the STDIN to a
file, and then use popen to call the process as
process < TMPFILE and then to read the output via a file descriptor.
Thanks...
On Thu, 21 Sep 2000, Robert V. Zwink wrote:
>
> rzwink: http://www.php.net/manual/html/function.fopen.html
> rzwink:
> rzwink: The manual has some information about php defined constants
> rzwink: "php://stdin", "php://stdout", or "php://stderr"
> rzwink:
> rzwink: Does this help?
> rzwink:
> rzwink: Robert Zwink
> rzwink: http://zwink.levitate.org
> rzwink:
> rzwink:
> rzwink: ----- Original Message -----
> rzwink: From: "Steve Hsieh" <steveh@eecs.umich.edu>
> rzwink: To: <php-general@lists.php.net>
> rzwink: Sent: Saturday, September 16, 2000 6:40 PM
> rzwink: Subject: [PHP] Writing to process STDIN and reading its STDOUT
from PHP4?
> rzwink:
> rzwink:
> rzwink: > Can someone explain how I can send STDIN to a *process* and read
its
> rzwink: STDOUT
> rzwink: > from PHP4?
> rzwink: >
> rzwink: > The only function I could find in the manual that seemed
relevant was
> rzwink: > popen(), but the manual says that it is unidirectional only.
> rzwink: >
> rzwink: > There must be a better way than than writing to a temp file and
calling
> rzwink: the
> rzwink: > process via
> rzwink: > popen("process < tmpfile", "r") ... I hope ?
> rzwink: >
> rzwink: > Anyone willing to provide a simple example of the best way to do
this?
> rzwink: > Suppose, for example, I have a paragraph of text contained in
variable
> rzwink: > $text, and I want to pass this to the STDIN of a binary called
'program'
> rzwink: and
> rzwink: > read its STDOUT back into PHP4.
> rzwink: >
> rzwink: > Thanks in advance!
> rzwink: >
> rzwink: >
> rzwink: >
> rzwink: > --
> rzwink: > PHP General Mailing List (http://www.php.net/)
> rzwink: > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> rzwink: > For additional commands, e-mail: php-general-help@lists.php.net
> rzwink: > To contact the list administrators, e-mail:
php-list-admin@lists.php.net
> rzwink: >
> rzwink:
> rzwink:
> rzwink:
>
> --
> ------------------------------------------------
> Yurais Fernández Leal, Systems Administrator
> Public Health Network Santiago de Cuba
> yurais@medired.scu.sld.cu
> http://www.scu.sld.cu/
> Phone: (53) 226-54204
> (home) (53) 226-51556
> FAX: (53) 226-54204
> ICQ: 33792610
> ------------
>