php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13084 can't pipe into php script
Submitted: 2001-08-31 14:32 UTC Modified: 2002-01-06 07:33 UTC
From: cynic@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0CVS-2001-08-31 OS: NT 5 SP 1
Private report: No CVE-ID: None
 [2001-08-31 14:32 UTC] cynic@php.net
cvs up -r PHP_4_0_7 on both machines done around 17:30 GMT.

on NT5 (standard cmd shell), attempt to pipe into the PHP 
script fails, on FreeBSD it works fine. I'd love to blame 
it on the stupid shell, but hey, I need this feature. :)

on the NT5 box, the phpx suffix has the following handler
for the "Run" action: c:\usr\local\bin\php.exe -q %1 %*

c:\temp> echo "foo bar baz" | test.phpx
The process tried to write to a nonexistent pipe.
^C

c:\temp> cat test.phpx
<?
$in = fopen('php://stdin', 'r');
while(!feof($in)){
    echo fgets($in, 4096);
}
echo "\n";
?>

c:\temp>


[cynic(cynic)@freepuppy bin]$ echo "foo bar baz" | ./test.phpx
foo bar baz

[cynic(cynic)@freepuppy bin]$ cat test.phpx 
#!/tmp/php-4.0.7/bin/php -q
<?
$in = fopen('php://stdin', 'r');
while(!feof($in)){
    echo fgets($in, 4096);
}
echo "\n";
?>

[cynic(cynic)@freepuppy bin]$ uname -a
FreeBSD freepuppy 4.3-RELEASE-p14 FreeBSD 4.3-RELEASE-p14 #0: \
Tue Aug 28 15:45:24 CEST 2001     \
toor@freepuppy.infosite.cz:/usr/obj/usr/src/sys/FREEPUPPY  i386

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-14 14:34 UTC] yohgaki@php.net
Any update for this report?
 [2002-01-06 07:33 UTC] sander@php.net
AFAIK, the problem is that you can't just connect an extension to a executable on Windows for use with the commandline. The binding you made only works in Explorer. This is really not a PHP problem... 

You might try the workaround to call the PHP executable with the script as argument:
echo foo bar baz | php test.phpx
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC