Re: Piping and the CLI parser

From: Date: Wed, 06 Aug 2003 15:20:49 +0000
Subject: Re: Piping and the CLI parser
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-158498@lists.php.net to get a copy of this message
Hi, Tuesday, August 5, 2003, 3:25:47 PM, you wrote: NF> Greets everybody. NF> My question regards psuedo-DOS (XP cmd.exe) piping and the CLI php parser. NF> If you could help please continue reading. NF> The documention specifies that the CLI php parser "sets up" STDIN and its NF> kin. NF> It does in fact work fine assuming the STDIN is the console, but while I was NF> just toying around with my File Type default command (setting it up WinXP so NF> that 'foobar.php arg1 arg2' entered at the command line actually executes NF> the script with arguments), I attempted some piping; which, through very NF> shallow research, I've come to think uses STDIN. NF> It fails; no piping whatsoever. Even the simplest 'dir | echo.php', where NF> echo just implodes() $argv and echoes, gives no output. NF> Is my suspicion that the CLI php parser does not set up STDIN to receive NF> from a pipe correct, or am I missing something here? NF> Thank you very much for your time, NF> Nick NF> ps - the type of File Type work I used to make the command line work is NF> described here: NF> http://www.php.net/manual/en/features.commandline.php -> NF> do an in-page NF> search for "phpNOSPAM" to find the comment quickly NF> pps - if someone could try similar piping on a *nix box, I'd be interested NF> to know how that goes You need to do something like this while(!feof(STDIN)) { echo fgets(STDIN, 1024); } stdin is a file stream not part of the command line arguments Note that this simple code will sit there for ever if you have no input or till you send it ^d (tested on linux) -- regards, Tom

« previous php.general (#158498) next »