<?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 Script Quick Help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212613#M168784</link>
    <description>NO points here please.&lt;BR /&gt;A typo in the previous post, in my haste to get a response in.&lt;BR /&gt;&lt;BR /&gt;[  "${aaa}"  =  "${bbb}"  ]&lt;BR /&gt;&lt;BR /&gt;missed a doublequote on the previous response.&lt;BR /&gt;</description>
    <pubDate>Mon, 08 Mar 2004 15:41:08 GMT</pubDate>
    <dc:creator>Chris Watkins_1</dc:creator>
    <dc:date>2004-03-08T15:41:08Z</dc:date>
    <item>
      <title>Shell Script Quick Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212607#M168778</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Would anyone help with this short script as why it is not getting through?&lt;BR /&gt;&lt;BR /&gt;---------------------------------------&lt;BR /&gt;The script is to check Oracle listener whether it is up, if not, start it, if yes, exit.&lt;BR /&gt;&lt;BR /&gt;It runs under Oracle, thus lsnrctl can start right there.&lt;BR /&gt;&lt;BR /&gt;****************************&lt;BR /&gt;lsnrctl status &amp;gt; /disk3/test/t1&lt;BR /&gt;aaa=`grep 'The command completed successfully' /disk3/test/t1`&lt;BR /&gt;bbb='The command completed successfully'&lt;BR /&gt;ccc='TNS:no listener'&lt;BR /&gt;&lt;BR /&gt;if [$aaa=$bbb]; then&lt;BR /&gt;  exit&lt;BR /&gt;else&lt;BR /&gt;  if [$aaa=$ccc]; then&lt;BR /&gt;     lsnrctl start&lt;BR /&gt;  fi&lt;BR /&gt;fi&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;******************************&lt;BR /&gt;&lt;BR /&gt;Error:&lt;BR /&gt;&lt;BR /&gt;listen_test[6]: [=The:  not found.&lt;BR /&gt;listen_test[9]: [=TNS:no:  not found.&lt;BR /&gt;---------------------------------------&lt;BR /&gt;&lt;BR /&gt;Very appreciated.&lt;BR /&gt;&lt;BR /&gt;Steven</description>
      <pubDate>Mon, 08 Mar 2004 15:26:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212607#M168778</guid>
      <dc:creator>Steven Chen_1</dc:creator>
      <dc:date>2004-03-08T15:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Quick Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212608#M168779</link>
      <description>Try this:&lt;BR /&gt;&lt;BR /&gt;if [ "$aaa" = "$bbb" ] ; then&lt;BR /&gt;exit&lt;BR /&gt;else&lt;BR /&gt;if [ "$aaa" = "$ccc" ] ; then&lt;BR /&gt;lsnrctl start&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Note the extra spaces and quotes.  What shell are you using for this?  If POSIX, do a 'man sh_posix' for information on the syntax for the if statement.  It is very syntax dependent.</description>
      <pubDate>Mon, 08 Mar 2004 15:30:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212608#M168779</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2004-03-08T15:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Quick Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212609#M168780</link>
      <description>Be sure their are spaces around the "[" and "]". Also it is best to enclose your variables in double quotes. Example-&lt;BR /&gt; &lt;BR /&gt;if [ "$aaa" = "$bbb" ] ; then&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 08 Mar 2004 15:30:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212609#M168780</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-03-08T15:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Quick Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212610#M168781</link>
      <description>You probably also should enclose your values for bbb and ccc in double quotes ( " ) instead of single quotes ( ' ).  For readability I would also modify aaa to be:&lt;BR /&gt;&lt;BR /&gt;aaa=$(grep "The command completed successfully"  /disk3/test/t1)&lt;BR /&gt;&lt;BR /&gt;It will work exactly the same and is much more readable than using the back-ticks ( ` ).</description>
      <pubDate>Mon, 08 Mar 2004 15:34:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212610#M168781</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2004-03-08T15:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Quick Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212611#M168782</link>
      <description>You have several problems:&lt;BR /&gt;&lt;BR /&gt;if [$aaa=$bbb]&lt;BR /&gt;should be:&lt;BR /&gt;if [ "${aaa}" = "${bbb}" ]&lt;BR /&gt;then&lt;BR /&gt;especialy note the white space after '[' and before ']'. Also, your variables should be protected bu quotes so that null strings don't clobber test.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You will also find this test to be much simpler:&lt;BR /&gt;&lt;BR /&gt;lsnrctl status &amp;gt; tmpfile&lt;BR /&gt;grep -q "This command completed sucessfully" tmpfile&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;then&lt;BR /&gt;echo "OK"&lt;BR /&gt;else&lt;BR /&gt;echo "Bad"&lt;BR /&gt;fi&lt;BR /&gt; &lt;BR /&gt;The -q option says only report the status of the grep; 0 = found. &lt;BR /&gt;&lt;BR /&gt;The '[[   ]]' uses the POSIX and Korn shell's internal test whereas '[  ]' spawns the external test command. The internal is more efficient although you can continuey to use the external.&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Mar 2004 15:35:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212611#M168782</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-03-08T15:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Quick Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212612#M168783</link>
      <description>Argh!&lt;BR /&gt;So hard to reply first here  :-)&lt;BR /&gt;As mentioned... you have two troubles.&lt;BR /&gt;&lt;BR /&gt;Double quote the variables, and space around the brackets.&lt;BR /&gt;ie...&lt;BR /&gt;[ "${aaa} = "${bbb}" ]      &lt;BR /&gt;&lt;BR /&gt;...will work just fine.</description>
      <pubDate>Mon, 08 Mar 2004 15:36:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212612#M168783</guid>
      <dc:creator>Chris Watkins_1</dc:creator>
      <dc:date>2004-03-08T15:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Quick Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212613#M168784</link>
      <description>NO points here please.&lt;BR /&gt;A typo in the previous post, in my haste to get a response in.&lt;BR /&gt;&lt;BR /&gt;[  "${aaa}"  =  "${bbb}"  ]&lt;BR /&gt;&lt;BR /&gt;missed a doublequote on the previous response.&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Mar 2004 15:41:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212613#M168784</guid>
      <dc:creator>Chris Watkins_1</dc:creator>
      <dc:date>2004-03-08T15:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script Quick Help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212614#M168785</link>
      <description>Steven,&lt;BR /&gt;&lt;BR /&gt;Clay's script should be the only one that actually works, even though everyone else has offered you good advice on syntax.&lt;BR /&gt;&lt;BR /&gt;The reason I say this is because you're checking for "The command completed successfully" using grep on a file.  Since you're just running a plain grep, you'll *only* get matches.  So, $aaa can *never* match $ccc.&lt;BR /&gt;&lt;BR /&gt;Back to Clay's script.  All he's doing is checking to see if there was a match and then doing something with that information.  And that's all you really need here.  Just modify the "OK" and "Bad" results to do whatever you actually want and you should be fine.&lt;BR /&gt;&lt;BR /&gt;Hehe, having said all this, I sure hope I'm not missing something obvious!!!&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Seth</description>
      <pubDate>Tue, 09 Mar 2004 00:13:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-quick-help/m-p/3212614#M168785</guid>
      <dc:creator>Seth Parker</dc:creator>
      <dc:date>2004-03-09T00:13:50Z</dc:date>
    </item>
  </channel>
</rss>

