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.n

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 opene

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 sti

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.

Re: [PHP] stdout as input

2009-09-24 Thread Tommy Pham
- Original Message > From: Christoph Boget > To: PHP General > 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 find but couldn

[PHP] stdout as input

2009-09-24 Thread Christoph Boget
I've read the section in the docs about i/o streams and other related sections I was able to find but couldn't figure out how to do what I need. From the command line, I'm trying to pipe stdout in to my php script which should then see it as input. A simplistic example would be: echo bob | myScr