note 70581 modified in function.popen by danbrown
| From: | danbrown@php.net | Date: | Mon, 02 Mar 2009 13:35:13 +0000 |
| Subject: | note 70581 modified in function.popen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151325@lists.php.net to get a copy of this message | ||
Note that under Windows, if you are trying to write data to be available to your pipe's STDIN,
you may need to execute php directly, rather than depending on file associations.
<?php
// with $cmd set to 'foo.php', STDIN comes up blank.
// with $cmd set to 'php foo.php', STDIN gets filled
// (assuming php.exe is in your path)
$cmd = 'foo.php';
if ( ($fh = popen($cmd, 'w')) === false )
die("Open failed: ${php_errormsg}\n");
fwrite($fh, "Line one\nLine two\n");
pclose($fh);
?>
--was--
Note that under Windows, if you are trying to write data to be available to your pipe's STDIN,
you may need to execute php directly, rather than depending on file associations.
<?
// with $cmd set to 'foo.php', STDIN comes up blank.
// with $cmd set to 'php foo.php', STDIN gets filled
// (assuming php.exe is in your path)
$cmd = 'foo.php';
if ( ($fh = popen($cmd, 'w')) === false )
die("Open failed: ${php_errormsg}\n");
fwrite($fh, "Line one\nLine two\n");
pclose($fh);
?>
http://php.net/manual/en/function.popen.php