<div dir="ltr">Ivan,<br><br><div><div class="gmail_extra">| wgrib2 -v 2016101212.gfs.t12z.pgrb2f001 | grep ERROR<br><br></div><div class="gmail_extra">does not work because the error message is sent to STDERR. <br></div><div class="gmail_extra">It depends on the shell but in bash,<br><br> wgrib2 -v 2016101212.gfs.t12z.pgrb2f00 2>stderr.txt<br><br></div><div class="gmail_extra">will send the error messages to stderr.txt <br><br></div><div class="gmail_extra">My (bash) suggestion is<br><br></div><div class="gmail_extra">wgrib2 2016101212.gfs.t12z.pgrb2f001 > tmp.inv<br></div><div class="gmail_extra"># now to check the return code<br></div><div class="gmail_extra">if ["$?" -ne 0 ] ; then<br></div><div class="gmail_extra"> echo "ERROR"<br></div><div class="gmail_extra"> do_something<br></div><div class="gmail_extra">fi<br><br></div><div class="gmail_extra"># since is is possible that you got no file or a smaller but complete file<br></div><div class="gmail_extra"># check the number of lines in the inventory .. see if you got what you want<br><br></div><div class="gmail_extra">N_REC=22<br></div><div class="gmail_extra">if [ "$N_REC" -ne `wc -n <tmp.inv` ] ; then<br></div><div class="gmail_extra"> echo "ERROR2"<br></div><div class="gmail_extra"> do_something<br></div><div class="gmail_extra">fi<br></div><div class="gmail_extra">rm tmp.inv<br><br></div><div class="gmail_extra">Wesley<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 12, 2016 at 5:48 PM, Ivan Toman <span dir="ltr"><<a target="_blank" href="mailto:ivtoman@inet.hr">ivtoman@inet.hr</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Hello Jeff,<br>
<br>
I do compare file sizes currently, but as they change little bit, it is<br>
still not too robust. I'm trying to find fail proof solution.<br>
<br>
So as I said, I can't capture response from wgrib2 into variable for<br>
some reason. See these two examples:<br>
<br>
Example 1) Capturing date output to variable:<br>
$ response=`date`<br>
$ echo $response<br>
Wed Oct 12 20:50:46 UTC 2016<br>
<br>
Works just fine.<br>
<br>
<br>
Wgrib2 error:<br>
wgrib2 -v 2016101212.gfs.t12z.pgrb2f001 | grep ERROR<br>
<br>
*** FATAL ERROR: rd_grib2_msg_seq_file, read outside of file, bad grib<br>
file ***<br>
<br>
<br>
Example 2) Trying to capture ERROR from wgrib2:<br>
$ response=`wgrib2 -v 2016101212.gfs.t12z.pgrb2f001 | grep ERROR`<br>
<br>
*** FATAL ERROR: rd_grib2_msg_seq_file, read outside of file, bad grib<br>
file ***<br>
$ echo $response<br>
<br>
<br>
Nothing is returned. Empty variable. That is what I try to fix..<br>
<br>
Thank you,<br>
Ivan Toman<br>
<br>
______________________________<wbr>_________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a target="_blank" rel="noreferrer" href="http://gradsusr.org/mailman/listinfo/gradsusr">http://gradsusr.org/mailman/<wbr>listinfo/gradsusr</a><br>
</blockquote></div><br></div></div></div>