#!/usr/bin/php -q
<?php
stream_set_blocking(STDIN,FALSE);
while(!feof(STDIN)) $stdin .= fread(STDIN,1024);
if($stdin) echo $stdin;
else echo "표준입력값이
없군요..";
?>
PHP5
#/usr/local/bin/php -q
<?php
## get STDIN
##
function stdin()
{
$stdin = '';
stream_set_blocking(STDIN,FALSE);
$stream = array(STDIN);
while(@stream_select($stream,$w=NULL,$e=NULL,0,500000) !== FALSE)
{
$buf = fread(STDIN,1024);
if(!trim($buf)) break;
$stdin .= $buf;
}
if(!$stdin = trim($stdin)) return array();
$stdin = preg_split('/\s+/',str_replace('\ ','\__SPACE__',$stdin));
$stdin = preg_replace('/\\\\__SPACE__/',' ',$stdin);
return $stdin;
}
?>
|