<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: If then statement help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302178#M184012</link>
    <description>Couple of ways.&lt;BR /&gt;&lt;BR /&gt;1. Getting the return value of the previous command and testing it for success.&lt;BR /&gt;&lt;BR /&gt;grep -q oracle /export/home/mduru/vxdisk.list&lt;BR /&gt;RESP=$?&lt;BR /&gt;if [ $RESP = 0 ]&lt;BR /&gt;then&lt;BR /&gt;mailx -s ....&lt;BR /&gt;else&lt;BR /&gt;echo "no listing"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;2. Directly testing the command with if&lt;BR /&gt;&lt;BR /&gt;if grep -q oracle /export/home/mduru/vxdisk.list&lt;BR /&gt;then&lt;BR /&gt;mailx -s ...&lt;BR /&gt;else&lt;BR /&gt;echo "no listing"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;There are few other ways. I like the first way as it is more readable to me.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
    <pubDate>Thu, 10 Jun 2004 16:33:29 GMT</pubDate>
    <dc:creator>Sridhar Bhaskarla</dc:creator>
    <dc:date>2004-06-10T16:33:29Z</dc:date>
    <item>
      <title>If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302176#M184010</link>
      <description>Hi, I am still learning shell programming: Please help me with this script. It keeps returning true even when there is no string "oracle" inside the file.&lt;BR /&gt;&lt;BR /&gt;if [ 'cat /export/home/mduru/vxdisk.list|grep oracle' &amp;gt; /dev/null ]&lt;BR /&gt;&lt;BR /&gt;then mailx -s "unix mail test" melduru@yahoo.com st&lt;BR /&gt;else echo "no listing"&lt;BR /&gt;fi;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Mel&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jun 2004 16:20:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302176#M184010</guid>
      <dc:creator>Mel_12</dc:creator>
      <dc:date>2004-06-10T16:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302177#M184011</link>
      <description>How about something like:&lt;BR /&gt;&lt;BR /&gt;COUNT=$(grep -c oracle  /export/home/mduru/vxdisk.list)&lt;BR /&gt;&lt;BR /&gt;if [ "${COUNT}" &amp;gt; 0 ] ; then&lt;BR /&gt; mailx -s "unix mail test" melduru@yahoo.com else&lt;BR /&gt;echo "nno listing"&lt;BR /&gt;fi</description>
      <pubDate>Thu, 10 Jun 2004 16:29:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302177#M184011</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2004-06-10T16:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302178#M184012</link>
      <description>Couple of ways.&lt;BR /&gt;&lt;BR /&gt;1. Getting the return value of the previous command and testing it for success.&lt;BR /&gt;&lt;BR /&gt;grep -q oracle /export/home/mduru/vxdisk.list&lt;BR /&gt;RESP=$?&lt;BR /&gt;if [ $RESP = 0 ]&lt;BR /&gt;then&lt;BR /&gt;mailx -s ....&lt;BR /&gt;else&lt;BR /&gt;echo "no listing"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;2. Directly testing the command with if&lt;BR /&gt;&lt;BR /&gt;if grep -q oracle /export/home/mduru/vxdisk.list&lt;BR /&gt;then&lt;BR /&gt;mailx -s ...&lt;BR /&gt;else&lt;BR /&gt;echo "no listing"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;There are few other ways. I like the first way as it is more readable to me.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Thu, 10 Jun 2004 16:33:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302178#M184012</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-06-10T16:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302179#M184013</link>
      <description>No points for the first response please -- I don't think its gonna work.  This should though:&lt;BR /&gt;&lt;BR /&gt;COUNT=$(grep -c oracle /export/home/mduru/vxdisk.list)&lt;BR /&gt;&lt;BR /&gt;if (( ${COUNT} &amp;gt; 0 )) ; then&lt;BR /&gt;mailx -s "unix mail test" melduru@yahoo.com else&lt;BR /&gt;echo "nno listing"&lt;BR /&gt;fi  &lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jun 2004 16:34:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302179#M184013</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2004-06-10T16:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302180#M184014</link>
      <description>FILE=/export/home/mduru/vxdisk.list&lt;BR /&gt;count=`grep -q oracle $FILE | wc -l`&lt;BR /&gt;if [ $count -gt 0 ]&lt;BR /&gt;then&lt;BR /&gt;mailx -s "unix mail test" melduru@yahoo.com &amp;lt; $FILE&lt;BR /&gt;else&lt;BR /&gt;echo "Nothing found to mail"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hope this helps&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jun 2004 16:40:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302180#M184014</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2004-06-10T16:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302181#M184015</link>
      <description>Thanks guys for your quick response. I have assigned points based upon the usefullness of the replies. I wanted a single line command as presented by  Sridhar and it worked beautifully. I had to strike the -q from the grep as the system shouted foul play "illegal use of ...&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Mel</description>
      <pubDate>Thu, 10 Jun 2004 17:00:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302181#M184015</guid>
      <dc:creator>Mel_12</dc:creator>
      <dc:date>2004-06-10T17:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302182#M184016</link>
      <description>grep -q doesn't work? What version of HP-UX are you using? -q has been around for a long time (at least a decade). What does your man page for grep say about -q?&lt;BR /&gt; &lt;BR /&gt;For readability (and to avoid using an obsolete and deprecated shell constructs, the grave accents), here's a simpler version:&lt;BR /&gt; &lt;BR /&gt;MYFILE=/export/home/mduru/vxdisk.list&lt;BR /&gt;if $(grep -q $MYFILE)&lt;BR /&gt;then&lt;BR /&gt;mailx -s "stuff.." me@yahoo.com &amp;lt; $MYFILE&lt;BR /&gt;else&lt;BR /&gt;echo "no listing"&lt;BR /&gt;fi&lt;BR /&gt; &lt;BR /&gt;See man sh-posix or man ksh concerning grave accents. Note that $(...) is also faxable whereas grave accents are almost always lost or copied incorrectly.</description>
      <pubDate>Thu, 10 Jun 2004 20:35:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302182#M184016</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2004-06-10T20:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302183#M184017</link>
      <description>Hi (Again),&lt;BR /&gt;&lt;BR /&gt;If you are really interested in one line, you can actually use&lt;BR /&gt;&lt;BR /&gt;grep -q oracle /export/home/mduru/vxdisk.list &amp;amp;&amp;amp; mailx -s "unix mail test" melduru@yahoo.com &amp;lt; /export/home/mduru/vxdisk.list&lt;BR /&gt;&lt;BR /&gt;Looking at /export structure, I feel yours is a SUN/Solaris system. grep -q is equivalent to " &amp;gt; /dev/null 2&amp;gt;&amp;amp;1".&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Thu, 10 Jun 2004 22:25:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302183#M184017</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-06-10T22:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: If then statement help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302184#M184018</link>
      <description>Sridhar!!!!!! is a natural. I am impressed you were able to decode my solaris system usage. Not to offend anyone, I support both platforms, HP and Solaris under the capacity of Oracle DBA. Bill, please go easy on some of us. Afterall, you have been fully decorated with all those points etc.... Again, I am impressed with the timely responses on this forum.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Mel</description>
      <pubDate>Fri, 11 Jun 2004 12:21:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-then-statement-help/m-p/3302184#M184018</guid>
      <dc:creator>Mel_12</dc:creator>
      <dc:date>2004-06-11T12:21:47Z</dc:date>
    </item>
  </channel>
</rss>

