<?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: Scripting Question in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648145#M102400</link>
    <description>You can also use if-elif-else with date also.&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;downtime_type=$($BINDIR/schedule $nodename)&lt;BR /&gt;if [ "${downtime_type}" = "A" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "`date +'%b %d %X'` Message 1" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 1&lt;BR /&gt;elif [ "${downtime_type}" = "B" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "`date +'%b %d %X'` Message 2" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 0&lt;BR /&gt;elif [ "${downtime_type}" = "C" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "`date +'%b %d %X'` Message 3" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 1&lt;BR /&gt;else&lt;BR /&gt;  sendsms "Message 4" "TT0001" "MYServer"&lt;BR /&gt;  echo "`date +'%b %d %X'` sendsms Message 4 TT0001 MYServer" &amp;gt;&amp;gt; script.log&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# END&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;hth.</description>
    <pubDate>Fri, 14 Oct 2005 04:06:55 GMT</pubDate>
    <dc:creator>Muthukumar_5</dc:creator>
    <dc:date>2005-10-14T04:06:55Z</dc:date>
    <item>
      <title>Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648132#M102387</link>
      <description>Below is the code fragment:&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "A" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 1"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "B" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 2"&lt;BR /&gt;exit 0&lt;BR /&gt;fi&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "C" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 3"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;sendsms "Message 4" "TT0001" "MYServer"&lt;BR /&gt;&lt;BR /&gt;"schedule" is another script called to check a textfile for values.&lt;BR /&gt;&lt;BR /&gt;Based on the code fragment, lets assuming that "schedule $nodename" is suppose to return "A". Is there any chance that the "sendsms" is run before the "schedule" could return the value? (esp in the scenario that the main script is triggered many times simultaneously) &lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 20:31:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648132#M102387</guid>
      <dc:creator>Malcolm Neo_1</dc:creator>
      <dc:date>2005-10-12T20:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648133#M102388</link>
      <description>No. If schedule returns A then the script will exit before executing sendsms.&lt;BR /&gt;&lt;BR /&gt;It would appear that 'schedule' returned something other then A, B, or C under those high contention situation. Maybe it failed outright?.&lt;BR /&gt;&lt;BR /&gt;I would capture the return value in a variable and include that in the senssms text, as well as the nodename that triggered it.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 20:37:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648133#M102388</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-10-12T20:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648134#M102389</link>
      <description>On the script,&lt;BR /&gt;&lt;BR /&gt;echo "Message #" is written to a test file.&lt;BR /&gt;&lt;BR /&gt;i.e. echo "Message #" &amp;gt;&amp;gt; script.log&lt;BR /&gt;&lt;BR /&gt;and for the last part of the script where the sendsms is run, I have something like this:&lt;BR /&gt;&lt;BR /&gt;echo "sendsms Message 4 TT0001 MYServer" &amp;gt;&amp;gt; script.log&lt;BR /&gt;&lt;BR /&gt;The funny thing is when I look back at the log.&lt;BR /&gt;&lt;BR /&gt;I found the follow text in the follow order:&lt;BR /&gt;sendsms Message 4 TT0001 MYServer&lt;BR /&gt;Message #&lt;BR /&gt;&lt;BR /&gt;In the normal situation, "Message #" should be returned and the script should end and "sendsms Message 4 TT0001 MYServer" should not appear.&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 21:03:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648134#M102389</guid>
      <dc:creator>Malcolm Neo_1</dc:creator>
      <dc:date>2005-10-12T21:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648135#M102390</link>
      <description>your second message tells me that when you run your script, you are redirecting the output to this script.log or something you are telling is inconsistent.&lt;BR /&gt;&lt;BR /&gt;if you can tell what you are really after, i.e., what you want this script to do, maybe the help gets better.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 21:40:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648135#M102390</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-10-12T21:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648136#M102391</link>
      <description>&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "A" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 1"&lt;BR /&gt;exitFLAG=1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "B" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 2"&lt;BR /&gt;exitFLAG=0&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "C" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 3"&lt;BR /&gt;exitFLAG=1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;sendsms "Message 4" "TT0001" "MYServer"&lt;BR /&gt;exit $exitFLAG&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 21:48:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648136#M102391</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-10-12T21:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648137#M102392</link>
      <description>Your code really needs to use the case statement rather than if/else/fi. It's a lot easier to read and the last test catches all text not found in the previous tests:&lt;BR /&gt;&lt;BR /&gt;RESULT=$($BINDIR/schedule $nodename)&lt;BR /&gt; &lt;BR /&gt;case $RESULT in&lt;BR /&gt;A) echo "Message 1"&lt;BR /&gt; exit 1&lt;BR /&gt; &lt;BR /&gt;B) echo "Message 2"&lt;BR /&gt; exit 0&lt;BR /&gt; &lt;BR /&gt;C) echo "Message 3"&lt;BR /&gt; exit 1&lt;BR /&gt; &lt;BR /&gt;*) sendsms "Message 4" "TT0001" "MYServer"&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;The case statement is doing the comparison and allows for multiple choices, longer strings, use of regular expressions like *, and so on.</description>
      <pubDate>Wed, 12 Oct 2005 22:37:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648137#M102392</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-10-12T22:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648138#M102393</link>
      <description>Sorry for the confusion. This is what it should look like:&lt;BR /&gt;&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "A" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 1" &amp;gt;&amp;gt; script.log&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "B" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 2" &amp;gt;&amp;gt; script.log&lt;BR /&gt;exit 0&lt;BR /&gt;fi&lt;BR /&gt;if [ $BINDIR/schedule $nodename = "C" ]&lt;BR /&gt;then&lt;BR /&gt;echo "Message 3" &amp;gt;&amp;gt; script.log&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;sendsms "Message 4" "TT0001" "MYServer"&lt;BR /&gt;echo "sendsms Message 4 TT0001 MYServer" &amp;gt;&amp;gt; script.log&lt;BR /&gt;&lt;BR /&gt;The "if" conditions above is to check if there is a scheduled downtime. If yes, depending of what type of downtime, it will write it to the log file and then exit.&lt;BR /&gt;&lt;BR /&gt;In the case where there is no downtime recorded, all conditions should be invalid and a sms would be sent out and the message will be recorded in the same log file.&lt;BR /&gt;&lt;BR /&gt;However, this is what is seen on the script.log:&lt;BR /&gt;sendsms Message 4 TT0001 MYServer&lt;BR /&gt;Message 2&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Oct 2005 22:39:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648138#M102393</guid>
      <dc:creator>Malcolm Neo_1</dc:creator>
      <dc:date>2005-10-12T22:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648139#M102394</link>
      <description>You can try as,&lt;BR /&gt;&lt;BR /&gt;downtime_type=$($BINDIR/schedule $nodename)&lt;BR /&gt;&lt;BR /&gt;if [ "${downtime_type}" = "A" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "Message 1" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 1&lt;BR /&gt;elif [ "${downtime_type}" = "B" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "Message 2" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 0&lt;BR /&gt;elif [ "${downtime_type}" = "C" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "Message 3" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 1&lt;BR /&gt;else&lt;BR /&gt;  sendsms "Message 4" "TT0001" "MYServer"&lt;BR /&gt;  echo "sendsms Message 4 TT0001 MYServer" &amp;gt;&amp;gt; script.log&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;More than this, use Bill's case method. It is neat.&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Thu, 13 Oct 2005 02:57:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648139#M102394</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-13T02:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648140#M102395</link>
      <description>&lt;BR /&gt;Bill'ds case statement solution reminded me of an onder remark I forgot to make explicit...&lt;BR /&gt;&lt;BR /&gt;What if the $BINDIR/schedule result changes exactly between two steps. That is, while it was testing for A is was C, and when it tested for B is had already become A, but neither triggered a match.&lt;BR /&gt;&lt;BR /&gt;So in a concurrent environment you HAVE to first grab the result into a variable, then test it. It is not only the more efficient way to go about business, it is the only right way to do the job.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Oct 2005 06:29:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648140#M102395</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-10-13T06:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648141#M102396</link>
      <description>Are there any date codes or "begin â ¦end" statements written to the script.log file?&lt;BR /&gt;&lt;BR /&gt;Could it be that what you are seeing is yesterdays run of the script which sent the sms message and todays which generated message 2&lt;BR /&gt;&lt;BR /&gt;I also agree that your best bet is to put it into a case statement.&lt;BR /&gt;&lt;BR /&gt;H&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Oct 2005 08:42:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648141#M102396</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2005-10-13T08:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648142#M102397</link>
      <description>I would recommend putting a&lt;BR /&gt; &lt;BR /&gt;exec &amp;gt;&amp;gt;script.log 2&amp;gt;&amp;amp;1&lt;BR /&gt; &lt;BR /&gt;at the front of the script, so that all output gets redirected to script.log.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 13 Oct 2005 08:57:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648142#M102397</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-10-13T08:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648143#M102398</link>
      <description>You can also use the logger command to add entries to syslog, something like this:&lt;BR /&gt; &lt;BR /&gt;logger -p local5.warn "Message 2"</description>
      <pubDate>Thu, 13 Oct 2005 09:26:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648143#M102398</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-10-13T09:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648144#M102399</link>
      <description>Hi all,&lt;BR /&gt;thx for the reply. I have implemented the case statement and would try to test it out to see if it works. Thx for the help.</description>
      <pubDate>Fri, 14 Oct 2005 03:51:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648144#M102399</guid>
      <dc:creator>Malcolm Neo_1</dc:creator>
      <dc:date>2005-10-14T03:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648145#M102400</link>
      <description>You can also use if-elif-else with date also.&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;downtime_type=$($BINDIR/schedule $nodename)&lt;BR /&gt;if [ "${downtime_type}" = "A" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "`date +'%b %d %X'` Message 1" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 1&lt;BR /&gt;elif [ "${downtime_type}" = "B" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "`date +'%b %d %X'` Message 2" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 0&lt;BR /&gt;elif [ "${downtime_type}" = "C" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "`date +'%b %d %X'` Message 3" &amp;gt;&amp;gt; script.log&lt;BR /&gt;  exit 1&lt;BR /&gt;else&lt;BR /&gt;  sendsms "Message 4" "TT0001" "MYServer"&lt;BR /&gt;  echo "`date +'%b %d %X'` sendsms Message 4 TT0001 MYServer" &amp;gt;&amp;gt; script.log&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# END&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Fri, 14 Oct 2005 04:06:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-question/m-p/3648145#M102400</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-14T04:06:55Z</dc:date>
    </item>
  </channel>
</rss>

