[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PERL QUESTION (fwd)




===============================================================================
Robb Kambic                                Unidata Program Center
Software Engineer III                      Univ. Corp for Atmospheric Research
address@hidden             WWW: http://www.unidata.ucar.edu/
===============================================================================

---------- Forwarded message ----------
Date: Sat, 18 Sep 1999 11:47:57 -0400 (EDT)
From: Rob Cermak <address@hidden>
To: address@hidden
Subject: PERL QUESTION (fwd)

Hi ldm'ers,        NOTE: Read below for the question.

I'd figure I'd post this to this group in case there were other solutions
to the problem below.   The crux of the matter is the PIPE in the ldm
does not allow a string of commands to be run in batch.   The QAD
(quick and dirty) solution to extend PIPE support is posted below.  The
'exec' command in perl immediately exits the current program with the one
being exec'd, if successful.   There must be other solutions :)

Rob Cermak/IMCS - Floyd'ed banks of the Ole Raritan - visible again...

pqact.conf:
MCIDAS  ^(LWTOA3 .*)
        PIPE    /wx/ldm/bin/sat_process.pl

PERL
sat_process.pl:

#!/bin/perl
# sat_process.pl
# Use the current process ID ($$) as your temporary file -- this will not
# work if your system is blitzed with processes & files.  Process IDs
# generally run from 1 to 32767(?) in 32 bit mode.  If you have a
# heavy processing system, it might be possible to run into the
# situation where you write to the same temporary file.   
$tmpfile="/tmp/sat.$$";

# STEP 1 - save the LWTOA3 file
open(FN,">$tmpfile");
while(<STDIN>) {
  print FN;
}

# STEP 2 - process it - below is backquotes for command execution under
# perl.  If you want status messages (errors), put a print in front of
# the first backquote.
`/wx/ldm/bin/lwtoa3 -d /wx/data/mcidas -f $tmpfile`;

# STEP 3 - remove evidence
unlink($tmpfile);

# STEP 4 - proceed to your last step
# This program has better know what happend when lwtoa3 worked on
# the temporary file.
`/export/home/wxp/pgms/mcidas.pl`;

Rob Cermak              -:- address@hidden -:- W: 732-932-3704
I.M.C.S.                -:- Rutgers University      -:- F: 732-932-3036
71 Dudley Road          -:- Cook College            -:- WWW: njlug.
New Brunswick, NJ 08901 -:- Old Blake Hall, Rm 203  -:-       .rutgers.edu

---------- Forwarded message ----------
Date: Fri, 17 Sep 1999 11:04:34 -0400
From: Tom Grzelak <address@hidden>
To: address@hidden
Subject: PERL QUESTION

Rob,

Sorry to bug you but I have a pretty simple (I think) perl question that I
can't seem to resolve.

Remember LDM.  You can pipe data to a certain exectuable to produce output
which can then be further acted on by another program.  Right now, sat data
comes in, gets piped (in pqact.conf) to lwtoa3 and then I run a mcidas perl
script to convert the resulting AREA files to data files which WXP can
interpret.  The latter is run on a cron and takes whatever is available.
This is inefficient.  I would like to have the following:

Data comes in and gets piped to lwtoa3.  Once that is done, then my mcidas
perl script is run on the resulting data.

I need to know how to write a perl script which takes STDIN and pipes it to
a process.

I would modify my pqact.conf to read:

MCIDAS  ^(LWTOA3 .*)
        PIPE    /wx/ldm/bin/sat_process.pl

And sat_process.pl would be like:

#!/bin/perl

exec "<STDIN> | /wx/ldm/bin/lwtoa3 -d /wx/data/mcidas";
exec "/export/home/wxp/pgms/mcidas.pl";

stop;

But its that first pipe of STDIN that I don't know how to format.

Please help!  Thanks a bunch!
Tom

  
===============================================================
Tom Grzelak                          address@hidden
Manager - Computing Services
 ----> Center for Environmental Prediction
 ----> Department of Environmental Sciences  

Rutgers University
14 College Farm Road                    Voice: 732-932-4923     
New Brunswick, NJ 08901-8551            Fax: 732-932-8644
                http://www.envsci.rutgers.edu
===============================================================