Re: [ldm-users] understanding the PIPE action

Matt,

Here is a working php example:

<?php
$fp = fopen('php://stdin','r');
$data = "";
while(!feof($fp)) {
    $data .= fgets($fp,4096);
}
fclose($fp);
?>

You'd want to run the LDM pipe with -close option to make sure pqact closes the pipe while only sending one product to it.

daryl

On Sun, 7 Jun 2009, Matt Alonso wrote:

Hi Jeff,

I might be misunderstanding what you are looking to do but if you want to
feed the contents of a file - as STDIN - to a php script I think you need to
do this:

php /path/to/php/script.php < /path/to/input.txt

So your bash script should look like this:

#!/bin/sh
php /usr/local/ldm/decoders/test.php < "$1"


I believe the way you have it setup currently, PHP is treating the contents
of the files as individual arguments.  Please note that I have never
actually done or tested any of this so I will apologize now if it does not
work.  Also, based on my minimal experience w/all of this I would *THINK*
that the LDM PIPE action is fundamentally doing the same thing as my
proposed change for the shell script so if you just swap the php script for
the shell script in the pqact you might be ok.

One other thought is that it might be worthwhile to leave the process as is
where you dump the data to an actual file and then pipe that into PHP b/c
if, for some reason, there is a hiccup in apache or in the code itself, I
would think that the data you were attempting to ingest will no longer be
accessible.

If this doesn't work let me know and it might be helpful to see the actual
PHP src you are using.  Best of luck.

Cheers,
Matt

On Sun, Jun 7, 2009 at 3:02 PM, Jeffrey Lake - Admin <
admin@xxxxxxxxxxxxxxxxxxxx> wrote:

Thanks to Daryl and all,
I will leave it the way I currently have it set,
LDM writes it to a file, then fires off the php script to do
with it what is needed, I thought maybe I could eliminate
a step but probably not ..

-Jeff





--
/**
 * Daryl Herzmann
 * Assistant Scientist -- Iowa Environmental Mesonet
 * http://mesonet.agron.iastate.edu
 */



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the ldm-users archives: