Re: [PHP] stdout as input

2009-09-24 Thread Tommy Pham
- Original Message From: Christoph Boget christoph.bo...@gmail.com To: PHP General php-general@lists.php.net Sent: Thursday, September 24, 2009 6:51:56 AM Subject: [PHP] stdout as input I've read the section in the docs about i/o streams and other related sections I was able to

Re: [PHP] stdout as input

2009-09-24 Thread Christoph Boget
Isn't it simpler with http://www.php.net/manual/en/function.shell-exec.php ? Perhaps. But the command to execute would be relatively arbitrary. What I'm trying to do is set up a script that will filter the results of a grep. But what I'm grepping and where I'm starting from would change. I

Re: [PHP] stdout as input

2009-09-24 Thread bdunlap
echo bob | myScript.php In myScript.php, I'm doing:  $handle = popen( 'php://stdin', 'r' );  echo var_export( $handle, TRUE ) . \n\n; What output are you getting from those lines, and what were you expecting? $handle is just a resource, same as if you opened a regular file -- you still need

Re: [PHP] stdout as input

2009-09-24 Thread Shawn McKenzie
bdunlap wrote: echo bob | myScript.php In myScript.php, I'm doing: $handle = popen( 'php://stdin', 'r' ); echo var_export( $handle, TRUE ) . \n\n; What output are you getting from those lines, and what were you expecting? $handle is just a resource, same as if you opened a regular

Re: [PHP] stdout as input

2009-09-24 Thread Christoph Boget
Exactly.  And if you just want redirected data you can try: $data = file_get_contents(php://stdin); --or-- For an array of lines: $lines = file(php://stdin); This is exactly what I was looking for. Thanks Shawn and Ben! thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To