<?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: shell programming in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821051#M830178</link>
    <description>Hi Olga:&lt;BR /&gt;&lt;BR /&gt;Well, once you assign points there's no changing them! ;-)&lt;BR /&gt;&lt;BR /&gt;John Palmer makes a very good point.  You could leverage his suggestion like this too:&lt;BR /&gt;&lt;BR /&gt;# grep -q "/mnt " /etc/mnttab || ( echo "It's not mounted!";date )&lt;BR /&gt;&lt;BR /&gt;Notice that I let 'grep' open the '/etc/mnttab' rather than spawn a separate process to do so, like 'cat /etc/mnttab|grep...'.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 08 Oct 2002 15:45:54 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2002-10-08T15:45:54Z</dc:date>
    <item>
      <title>shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821041#M830168</link>
      <description>I need to capture the output of 'bdf|grep /mnt', if there is nothing, then do other tasks.&lt;BR /&gt;&lt;BR /&gt;Is there a better way to hadle this, other then capturing the output to a file?</description>
      <pubDate>Tue, 08 Oct 2002 14:57:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821041#M830168</guid>
      <dc:creator>Olga_1</dc:creator>
      <dc:date>2002-10-08T14:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821042#M830169</link>
      <description>you could pipe this output to awk instead of a file... and make the entire sting a variable that you can then check with an if loop&lt;BR /&gt;&lt;BR /&gt;on my system the 6th field on a line returned from bdf is the mount point... if your /mnt is not mounted, it will not be returned and MNT_CHECK should be null.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;MNT_CHECK = `bdf|grep /mnt | awk '{print $6}'`&lt;BR /&gt;echo ${MNT_CHECK} # just to see if you get what you expect...&lt;BR /&gt;&lt;BR /&gt;now set up some if statement that will verify your logic and execute other tasks... &lt;BR /&gt;&lt;BR /&gt;Ted</description>
      <pubDate>Tue, 08 Oct 2002 15:03:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821042#M830169</guid>
      <dc:creator>Ted Ellis_2</dc:creator>
      <dc:date>2002-10-08T15:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821043#M830170</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;You can check if the exit code was succesful&lt;BR /&gt;&lt;BR /&gt;bdf | grep /mnt&lt;BR /&gt;if [ $? != 1 ]&lt;BR /&gt;then&lt;BR /&gt;task&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 08 Oct 2002 15:03:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821043#M830170</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-10-08T15:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821044#M830171</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;How about:&lt;BR /&gt;&lt;BR /&gt;# bdf|grep -q /mnt &amp;amp;&amp;amp; echo "It's mounted!"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 08 Oct 2002 15:03:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821044#M830171</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-08T15:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821045#M830172</link>
      <description>export A=`bdf | grep /mnt `&lt;BR /&gt;&lt;BR /&gt;if [ $A = 0 ]&lt;BR /&gt;&lt;BR /&gt;then &lt;BR /&gt;&lt;BR /&gt;command&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Manoj Srivastava</description>
      <pubDate>Tue, 08 Oct 2002 15:10:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821045#M830172</guid>
      <dc:creator>MANOJ SRIVASTAVA</dc:creator>
      <dc:date>2002-10-08T15:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821046#M830173</link>
      <description>I wonder, how $A could ever get "0"?&lt;BR /&gt;&lt;BR /&gt;IMHO, James' approach is by far the coolest. :)</description>
      <pubDate>Tue, 08 Oct 2002 15:17:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821046#M830173</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2002-10-08T15:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821047#M830174</link>
      <description>Hi Olga:&lt;BR /&gt;&lt;BR /&gt;The concept here is that no file is used.  Rather the output of 'bdf' is piped to 'grep' which is run "quietly" (without output).  The return code of grep is examined and only if it is non-zero then is your command (or commands as the example shows) executed:&lt;BR /&gt;&lt;BR /&gt;# bdf|grep -q /mnt || ( echo "It's not mounted!";date )&lt;BR /&gt;&lt;BR /&gt;You can exchange the double pipe (||) for a double ampersand (&amp;amp;&amp;amp;) and invert the logic.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 08 Oct 2002 15:22:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821047#M830174</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-08T15:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821048#M830175</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;Thank you for the explanations.&lt;BR /&gt;I wanted to assighn you 10 points, but somehow it turned to 0. Can I modify it?</description>
      <pubDate>Tue, 08 Oct 2002 15:30:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821048#M830175</guid>
      <dc:creator>Olga_1</dc:creator>
      <dc:date>2002-10-08T15:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821049#M830176</link>
      <description>Checking /etc/mnttab would be quicker than running bdf.&lt;BR /&gt;&lt;BR /&gt;I would also recommend changing your grep arguments to only match for a filesystem called /mnt. All the above examples would also match something like /mntxxx or even /dev/vgxx/mnt...&lt;BR /&gt;&lt;BR /&gt;Something like:&lt;BR /&gt;&lt;BR /&gt;if bdf | grep -q " /mnt$"&lt;BR /&gt;then...&lt;BR /&gt;&lt;BR /&gt;or:&lt;BR /&gt;&lt;BR /&gt;if grep -q " /mnt " /etc/mnttab&lt;BR /&gt;then...&lt;BR /&gt;&lt;BR /&gt;Would do the trick.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Tue, 08 Oct 2002 15:31:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821049#M830176</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-10-08T15:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821050#M830177</link>
      <description>In addition to others .. a couple of ways ..&lt;BR /&gt;&lt;BR /&gt;var=$(bdf|grep /mnt)&lt;BR /&gt;if [[ $var != "" ]]&lt;BR /&gt;then&lt;BR /&gt;  # do your stuff here&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;if [[ $(bdf|grep /mnt|wc -l) -ne 0 ]]&lt;BR /&gt;then&lt;BR /&gt;  # do your stuff here&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Take note that "bdf" command may hung if you got stale NFS filesystem or bad FS. I'm in favor of "mount -v" instead.&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 15:37:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821050#M830177</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-10-08T15:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821051#M830178</link>
      <description>Hi Olga:&lt;BR /&gt;&lt;BR /&gt;Well, once you assign points there's no changing them! ;-)&lt;BR /&gt;&lt;BR /&gt;John Palmer makes a very good point.  You could leverage his suggestion like this too:&lt;BR /&gt;&lt;BR /&gt;# grep -q "/mnt " /etc/mnttab || ( echo "It's not mounted!";date )&lt;BR /&gt;&lt;BR /&gt;Notice that I let 'grep' open the '/etc/mnttab' rather than spawn a separate process to do so, like 'cat /etc/mnttab|grep...'.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 08 Oct 2002 15:45:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821051#M830178</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-08T15:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821052#M830179</link>
      <description>Folks, I like this thread... what about&lt;BR /&gt;&lt;BR /&gt;mount | grep -q '^/opt ' &amp;amp;&amp;amp; echo "Yo, brother."&lt;BR /&gt;&lt;BR /&gt;Should be more water-proof, I think. In general, I don't like reading /etc/mnttab directly.&lt;BR /&gt;&lt;BR /&gt;Regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Tue, 08 Oct 2002 16:05:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821052#M830179</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2002-10-08T16:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821053#M830180</link>
      <description>Hi Dietmar:&lt;BR /&gt;&lt;BR /&gt;Das ist sehr gut!&lt;BR /&gt;&lt;BR /&gt;Yes, I like that better.  It's short, matches exactly what (and only what it should) and executes very quickly.&lt;BR /&gt;&lt;BR /&gt;BTW, your new hat looks just like it was made for you! :-)) &lt;BR /&gt;&lt;BR /&gt;With warm regards...&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 17:07:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821053#M830180</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-10-08T17:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: shell programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821054#M830181</link>
      <description>Hi, James!&lt;BR /&gt;&lt;BR /&gt;Vielen Dank fuer die Blumen! :)&lt;BR /&gt;&lt;BR /&gt;Greetings to Sarasota.&lt;BR /&gt;&lt;BR /&gt;Dietmar.</description>
      <pubDate>Tue, 08 Oct 2002 18:24:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/2821054#M830181</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2002-10-08T18:24:21Z</dc:date>
    </item>
  </channel>
</rss>

