Re: getting STDIO
| From: | Joe Stump | Date: | Sat, 03 Feb 2001 00:22:35 +0000 |
| Subject: | Re: getting STDIO | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-37924@lists.php.net to get a copy of this message | ||
#!/path/to/php -q
<?
$fp = fopen('/dev/stdin','r');
if($fp)
{
while(!feof($fp))
{
$line = trim(fgets($fp,4096));
}
}
?>
chmod +x script.php
--Joe
On Fri, Feb 02, 2001 at 04:36:48PM -0300, Martin A. Marques wrote:
> I want to use PHP to build a script that would run from the comand line. Now
> me problem is how do I make PHP interpretate a chunk of text that is piped to
> it?
> Lets say my script is named script1.php and I do:
>
> $ less file1 | script1.php
>
> just like if I send variables with info with a put in the apache module
> version.
> How do I get that output?
>
> Saludos... :-)
>
> --
> System Administration: It's a dirty job,
> but someone told I had to do it.
> -----------------------------------------------------------------
> Martín Marqués email: martin@math.unl.edu.ar
> Santa Fe - Argentina http://math.unl.edu.ar/~martin/
> Administrador de sistemas en math.unl.edu.ar
> -----------------------------------------------------------------
>
> --
> 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
--
-------------------------------------------------------------------------------
Joe Stump, PHP Hacker, joestump98@yahoo.com -o)
http://www.miester.org http://www.care2.com
/\\
"It's not enough to succeed. Everyone else must fail" -- Larry Ellison _\_V
-------------------------------------------------------------------------------