[gradsusr] Use wgrib2 to check if grib2 file is valid
Love, Mr. Gary, Contractor, Code 7542
gary.love.ctr at nrlmry.navy.mil
Thu Oct 13 20:01:43 EDT 2016
Wesley,
Have you tried
| wgrib2 -v 2016101212.gfs.t12z.pgrb2f001 2>&1 | grep ERROR
The redirect, 2>&1, is supposed to add the results of STDERR to STDOUT.
Gary Love
From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org] On
Behalf Of Wesley Ebisuzaki - NOAA Federal
Sent: Thursday, October 13, 2016 6:02 AM
To: GrADS Users Forum
Subject: Re: [gradsusr] Use wgrib2 to check if grib2 file is valid
Ivan,
| wgrib2 -v 2016101212.gfs.t12z.pgrb2f001 | grep ERROR
does not work because the error message is sent to STDERR.
It depends on the shell but in bash,
wgrib2 -v 2016101212.gfs.t12z.pgrb2f00 2>stderr.txt
will send the error messages to stderr.txt
My (bash) suggestion is
wgrib2 2016101212.gfs.t12z.pgrb2f001 > tmp.inv
# now to check the return code
if ["$?" -ne 0 ] ; then
echo "ERROR"
do_something
fi
# since is is possible that you got no file or a smaller but complete file
# check the number of lines in the inventory .. see if you got what you want
N_REC=22
if [ "$N_REC" -ne `wc -n <tmp.inv` ] ; then
echo "ERROR2"
do_something
fi
rm tmp.inv
Wesley
On Wed, Oct 12, 2016 at 5:48 PM, Ivan Toman <ivtoman at inet.hr> wrote:
Hello Jeff,
I do compare file sizes currently, but as they change little bit, it is
still not too robust. I'm trying to find fail proof solution.
So as I said, I can't capture response from wgrib2 into variable for
some reason. See these two examples:
Example 1) Capturing date output to variable:
$ response=`date`
$ echo $response
Wed Oct 12 20:50:46 UTC 2016
Works just fine.
Wgrib2 error:
wgrib2 -v 2016101212.gfs.t12z.pgrb2f001 | grep ERROR
*** FATAL ERROR: rd_grib2_msg_seq_file, read outside of file, bad grib
file ***
Example 2) Trying to capture ERROR from wgrib2:
$ response=`wgrib2 -v 2016101212.gfs.t12z.pgrb2f001 | grep ERROR`
*** FATAL ERROR: rd_grib2_msg_seq_file, read outside of file, bad grib
file ***
$ echo $response
Nothing is returned. Empty variable. That is what I try to fix..
Thank you,
Ivan Toman
_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20161014/677c2dd9/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5433 bytes
Desc: not available
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20161014/677c2dd9/attachment.bin
More information about the gradsusr
mailing list