Re: Help with exec.

From: Date: Wed, 03 Mar 2010 13:27:42 +0000
Subject: Re: Help with exec.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-302508@lists.php.net to get a copy of this message
On Wed, 2010-03-03 at 13:04 +0000, Richard Quadling wrote: > On 3 March 2010 13:01, Paul Halliday <paul.halliday@gmail.com> wrote: > > I need to pipe some data to an external application. > > > > I have this: > > > > while ($row = mysql_fetch_array($theData[0])) { > > $src_ip[] = $row[0]; > > $dst_ip[] = $row[1]; > > $sig_desc[] = $row[2]; > > > > $rec ++; > > if ( $rec == $recCount ) { > > break; > > } > > } > > > > for ($i = 0; $i < sizeof($src_ip); $i++) { > > $tmpResult[] = "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n"; > > } > > > > > > The external program is called like: > > > > cat results.csv | theprogram outputfilename > > > > Is there a way mimic this w/o outputting $tmpResult to a file first? > > > > Thanks. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > I believe you can use popen() to open "theprogram" and pipe to it the > content and read back the results. All without writing to any files. > popen() either reads from a pipe or writes to a pipe, if I remember well, not both. Teus.

« previous php.general (#302508) next »