<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Wesley,<br>
      <br>
      Thank you very much again, you are very helpul as always,<br>
      <br>
      Ivan Toman<br>
      <br>
      <br>
      <br>
      On 10/14/2016 02:44 PM, Wesley Ebisuzaki - NOAA Federal wrote:<br>
    </div>
    <blockquote
cite="mid:CAMHOGekvpt_gxGoavfe3OgOt3vy_ig1VKxSLHq_6V+JVRVe4Fg@mail.gmail.com"
      type="cite">
      <div dir="ltr">Gary,<br>
        <div>
          <div class="gmail_extra"><br>
            <div class="gmail_quote">On Thu, Oct 13, 2016 at 8:01 PM,
              Love, Mr. Gary, Contractor, Code 7542 <span dir="ltr">&lt;<a
                  moz-do-not-send="true"
                  href="mailto:gary.love.ctr@nrlmry.navy.mil"
                  target="_blank">gary.love.ctr@nrlmry.navy.mil</a>&gt;</span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div link="blue" vlink="purple" lang="EN-US">
                  <div class="m_-6117770940686539107WordSection1">
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Wesley,</span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Have
                        you tried</span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">|    
                        wgrib2 -v <a moz-do-not-send="true"
                          href="tel:2016101212" value="+12016101212"
                          target="_blank">2016101212</a>.gfs.t12z.pgrb2f001
                        2&gt;&amp;1 | grep ERROR</span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">The
                        redirect, 2&gt;&amp;1,  is supposed to add the
                        results of STDERR to STDOUT.</span></p>
                  </div>
                </div>
              </blockquote>
              <div><br>
              </div>
              <div>You can do this but you need to check for two
                conditions<br>
                <br>
              </div>
              <div>   1) error detected by wgrib2; for example, the grib
                message is incomplete<br>
              </div>
              <div>   2) file is short but wgrib2 doesn't find an
                incomplete grib message.<br>
              </div>
              <div>          for example; the server's copy of the file
                is missing fields<br>
              </div>
              <div>                  or the transmission fortuitously
                stopped at the end of a message.<br>
                <br>
              </div>
              <div>Condition 2 requires you to read stdout.  Adding
                stderr to stdout makes life<br>
              </div>
              <div>confusing.  Otherwise it is a good suggestion.<br>
                <br>
              </div>
              <div>Wesley<br>
                <br>
              </div>
              <div> <br>
              </div>
              <div> <br>
              </div>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div link="blue" vlink="purple" lang="EN-US">
                  <div class="m_-6117770940686539107WordSection1">
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"></span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Gary
                        Love</span></p>
                    <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span></p>
                    <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">
                        <a moz-do-not-send="true"
                          href="mailto:gradsusr-bounces@gradsusr.org"
                          target="_blank">gradsusr-bounces@gradsusr.org</a>
                        [mailto:<a moz-do-not-send="true"
                          href="mailto:gradsusr-bounces@gradsusr.org"
                          target="_blank">gradsusr-bounces@<wbr>gradsusr.org</a>]
                        <b>On Behalf Of </b>Wesley Ebisuzaki - NOAA
                        Federal<br>
                        <b>Sent:</b> Thursday, October 13, 2016 6:02 AM<br>
                        <b>To:</b> GrADS Users Forum<br>
                        <b>Subject:</b> Re: [gradsusr] Use wgrib2 to
                        check if grib2 file is valid</span></p>
                    <p class="MsoNormal"> </p>
                    <div>
                      <p class="MsoNormal" style="margin-bottom:12.0pt">Ivan,</p>
                      <div>
                        <div>
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt">|     wgrib2 -v
                            <a moz-do-not-send="true"
                              href="tel:2016101212" value="+12016101212"
                              target="_blank">2016101212</a>.gfs.t12z.pgrb2f001
                            | grep ERROR</p>
                        </div>
                        <div>
                          <p class="MsoNormal">does not work because the
                            error message is sent to STDERR.  </p>
                        </div>
                        <div>
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt">It depends on
                            the shell but in bash,<br>
                            <br>
                                  wgrib2 -v <a moz-do-not-send="true"
                              href="tel:2016101212" value="+12016101212"
                              target="_blank">2016101212</a>.gfs.t12z.pgrb2f00
                            2&gt;stderr.txt</p>
                        </div>
                        <div>
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt">will send the
                            error messages to stderr.txt  </p>
                        </div>
                        <div>
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt">My (bash)
                            suggestion is</p>
                        </div>
                        <div>
                          <p class="MsoNormal">wgrib2 <a
                              moz-do-not-send="true"
                              href="tel:2016101212" value="+12016101212"
                              target="_blank">2016101212</a>.gfs.t12z.pgrb2f001
                            &gt; tmp.inv</p>
                        </div>
                        <div>
                          <p class="MsoNormal"># now to check the return
                            code</p>
                        </div>
                        <div>
                          <p class="MsoNormal">if ["$?" -ne 0 ] ; then</p>
                        </div>
                        <div>
                          <p class="MsoNormal">  echo "ERROR"</p>
                        </div>
                        <div>
                          <p class="MsoNormal">  do_something</p>
                        </div>
                        <div>
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt">fi</p>
                        </div>
                        <div>
                          <p class="MsoNormal"># since is is possible
                            that you got no file or a smaller but
                            complete file</p>
                        </div>
                        <div>
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt"># check the
                            number of lines in the inventory .. see if
                            you got what you want</p>
                        </div>
                        <div>
                          <p class="MsoNormal">N_REC=22</p>
                        </div>
                        <div>
                          <p class="MsoNormal">if [ "$N_REC" -ne `wc -n
                            &lt;tmp.inv` ] ; then</p>
                        </div>
                        <div>
                          <p class="MsoNormal">   echo "ERROR2"</p>
                        </div>
                        <div>
                          <p class="MsoNormal">   do_something</p>
                        </div>
                        <div>
                          <p class="MsoNormal">fi</p>
                        </div>
                        <div>
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt">rm tmp.inv</p>
                        </div>
                        <div>
                          <p class="MsoNormal">Wesley</p>
                        </div>
                        <div>
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt"> </p>
                          <div>
                            <p class="MsoNormal">On Wed, Oct 12, 2016 at
                              5:48 PM, Ivan Toman &lt;<a
                                moz-do-not-send="true"
                                href="mailto:ivtoman@inet.hr"
                                target="_blank">ivtoman@inet.hr</a>&gt;
                              wrote:</p>
                            <p class="MsoNormal">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 <a moz-do-not-send="true"
                                href="tel:2016101212"
                                value="+12016101212" target="_blank">2016101212</a>.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 <a
                                moz-do-not-send="true"
                                href="tel:2016101212"
                                value="+12016101212" target="_blank">2016101212</a>.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 moz-do-not-send="true"
                                href="mailto:gradsusr@gradsusr.org"
                                target="_blank">gradsusr@gradsusr.org</a><br>
                              <a moz-do-not-send="true"
                                href="http://gradsusr.org/mailman/listinfo/gradsusr"
                                target="_blank">http://gradsusr.org/mailman/<wbr>listinfo/gradsusr</a></p>
                          </div>
                          <p class="MsoNormal"> </p>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                <br>
                ______________________________<wbr>_________________<br>
                gradsusr mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
                <a moz-do-not-send="true"
                  href="http://gradsusr.org/mailman/listinfo/gradsusr"
                  rel="noreferrer" target="_blank">http://gradsusr.org/mailman/<wbr>listinfo/gradsusr</a><br>
                <br>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
gradsusr mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a>
<a class="moz-txt-link-freetext" href="http://gradsusr.org/mailman/listinfo/gradsusr">http://gradsusr.org/mailman/listinfo/gradsusr</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>