<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>--- On <B>Fri, 11/14/08, Eric Altshuler <I>&lt;ela@COLA.IGES.ORG&gt;</I></B> wrote:<BR></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">From: Eric Altshuler &lt;ela@COLA.IGES.ORG&gt;<BR>Subject: Re: Running Shell Script for grib2ctl /gribmap on crontab<BR>To: GRADSUSR@LIST.CINECA.IT<BR>Date: Friday, November 14, 2008, 3:03 AM<BR><BR><PRE>Zilore,

The grib2ctl.pl script requires wgrib to be in the user's path. When a job
runs under cron, the environment (including the path) is usually different than
if you run the job from an interactive login. Often, the PATH for a cron job
will not include $HOME/bin or '.', and sometimes /usr/local/bin is not
included either. Even though you provide full paths for grib2ctl.pl and gribmap,
it is likely that grib2ctl.pl cannot find the wgrib executable. There are two
things you could do:

1. Find the directory where the wgrib executable is located on your system, and
add it to the PATH environment variable, e.g. if it is in /usr/local/grads/bin,
then add this line near the beginning of your script:

export PATH=/usr/local/grads/bin:$PATH

2. Alternatively, edit the grib2ctl.pl script and look for the following line:

$wgrib='wgrib';

Change this to:

$wgrib='/usr/local/grads/bin/wgrib';

or wherever wgrib is located on your system.</PRE><PRE><DIV><FONT color=#0000ff>Eric,</FONT></DIV><DIV><FONT color=#0000ff>Thanks very much for explaining to me what exactly is happening.</FONT></DIV><DIV><FONT color=#0000ff>I am half there.</FONT></DIV><DIV><FONT color=#0000ff>As per your suggestions, I did three things:</FONT></DIV><DIV><FONT color=#0000ff>1. I added grib2ctl path in my shell profile file</FONT></DIV><DIV><FONT color=#0000ff>2. I put both paths to perl and to grib2ctl</FONT></DIV><DIV><FONT color=#0000ff>3. In grib2ctl.pl there is a system command 'system "wgrib $wflag -v..." ' which i changed to</FONT></DIV><DIV><FONT color=#0000ff>   'system "/usr/local/grads/bin/wgrib $wflag -v..." ' </FONT></DIV><DIV><FONT color=#0000ff>Now the ctl file is being created, but the idx file is not, though /usr/local/grads/bin/</FONT></DIV><DIV><FONT color=#0000ff>is on the path, and unfortunately gribmap is bianry so there is nowhere I can
 touch.</FONT></DIV><DIV><FONT color=#0000ff> </FONT></DIV><DIV><FONT color=#0000ff>&nbsp; </FONT><FONT color=#c00000>/usr/bin/perl /usr/local/bin/grib2ctl.pl -verf $model$cycle$grib_ext &gt; $model$cycle$ctl_ext<BR>&nbsp;&nbsp;/usr/local/grads/bin/gribmap -i $model$cycle$ctl_ext -v -e</FONT></DIV><DIV><FONT color=#000000>Thanks for the assistance.</FONT></DIV><DIV><FONT color=#c00000><FONT color=#000000>Zilore</FONT><BR></FONT><BR><BR></DIV>

Best regards,

Eric L. Altshuler
Assistant Research Scientist
Center for Ocean-Land-Atmosphere Studies
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA

E-mail: ela@cola.iges.org
Phone: (301) 902-1257
Fax: (301) 595-9793

----- Original Message -----
From: "zilore mumba" &lt;zmumba@YAHOO.COM&gt;
To: GRADSUSR@LIST.CINECA.IT
Sent: Thursday, November 13, 2008 2:08:08 AM GMT -05:00 US/Canada Eastern
Subject: Running Shell Script for grib2ctl /gribmap on crontab

Sincere apologies as my question is not purely Grads. I have a shell script
(code below) which:
1. concatenates files via the cat command;
2. runs grib2ctl to create a ctl
3. run gribmap
When I run the script manually (i.e. on the command line) it performs as
required.
When I run it through crontab, it concatenates files ok, but it creates a ctl
file which is empty and it does not create an idx file (even though I have
indicated the paths to where grib2ctl and gribmap are located)
Assistance will be appreciated.
Zilore.
Â
#
#!/bin/bash
#This script processes UKMO model data from RETIM-SYNERGIE and archives it on
#the ACMAD system. The cycles (or times) are 00 and 12.
#
ctl_ext=".ctl"
grib_ext=".grib"
UK_sufx="2"
dash="-"
model="ukmo"
#
model_dat=`date "+%Y%m%d"`
model_hr=`date "+%H"`
#
model_dat1=$( date -d "1 day" "+%Y%m%d" )
#
model_mon=`date "+%m"`
mon_name=`date "+%B"`
yr=`date "+%y"`
#
if [ $model_hr -gt "15" ]
  then
    cycle="12"
else
    cycle="00"
fi
#
base_dir="/home/Mumba/archive/$model_mon$dash$mon_name$yr"
#
      cd $base_dir/$model/$model_dat
#      pwd
      cat *H &gt; $model$cycle$grib_ext
      /usr/local/bin/grib2ctl.pl -verf $model$cycle$grib_ext &gt;
$model$cycle$ctl_ext
      /usr/local/grads/bin/gribmap -i $model$cycle$ctl_ext -v -e
      rm *H
  #
      mv $base_dir/$model/$model_dat1/*H $base_dir/$model/$model_dat
      cat *H &gt; $model$cycle$UK_suf$grib_ext
      /usr/local/bin/grib2ctl.pl -verf $model$cycle$UK_sufx$grib_ext
&gt; $model$cycle$UK_sufx$ctl_ext
      /usr/local/grads/bin/gribmap -i  $model$cycle$UK_sufx$ctl_ext
-v -e
      rm *H
   #
#
date
exit 0
</PRE></BLOCKQUOTE></td></tr></table><br>