Re: Accessing piped data in PHP shell script
| From: | David Yee | Date: | Fri, 01 Feb 2002 00:46:13 +0000 |
| Subject: | Re: Accessing piped data in PHP shell script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-83042@lists.php.net to get a copy of this message | ||
Oops, nevermind- I found the answer:
$fp = fopen("php://stdin", "r");
while(($buf=fgets($fp, 512)) != false) {
$input .= $buf;
}
echo "$input";
----- Original Message -----
From: "David Yee" <david@coolcomputing.com>
To: <php-general@lists.php.net>
Sent: Thursday, January 31, 2002 4:30 PM
Subject: [PHP] Accessing piped data in PHP shell script
> How can I access data/parameters piped into a PHP shell script? E.g:
>
> cat foo.txt | php -q myscript.php
>
> In this example I want to take the contents of foo.txt and store it into a
> variable/array in myscript.php. I tried $argv[] but no go. Thanks.
>
> David
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>