<?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: Error with script to compare two text strings in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622017#M38933</link>
    <description>Try putting a space around the equal size in the test statement, i.e.:&lt;BR /&gt;&lt;BR /&gt; MONTH="Nov"&lt;BR /&gt;if test $MONTH = "Jan"&lt;BR /&gt;then&lt;BR /&gt;MON=01&lt;BR /&gt;else MON=UNKNOWN&lt;BR /&gt;fi&lt;BR /&gt;echo "Month is $MONTH"&lt;BR /&gt;echo "Mon is $MON"&lt;BR /&gt;&lt;BR /&gt;Notice the space before and after the = in the 'if test' statement.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;-Santosh&lt;BR /&gt;</description>
    <pubDate>Thu, 29 Nov 2001 11:21:27 GMT</pubDate>
    <dc:creator>Santosh Nair_1</dc:creator>
    <dc:date>2001-11-29T11:21:27Z</dc:date>
    <item>
      <title>Error with script to compare two text strings</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622014#M38930</link>
      <description>Dear Colleagues, &lt;BR /&gt;&lt;BR /&gt;The script below tests to see if the value of the MONTH variable is "Jan". If so, it sets another variable called MON to 01 : &lt;BR /&gt;    MONTH="Nov"&lt;BR /&gt;     if test $MONTH="Jan"&lt;BR /&gt;     then&lt;BR /&gt;     MON=01&lt;BR /&gt;     else MON=UNKNOWN&lt;BR /&gt;     fi&lt;BR /&gt; echo "Month is $MONTH"&lt;BR /&gt; echo "Mon is $MON"&lt;BR /&gt;&lt;BR /&gt;When I run this, I get : &lt;BR /&gt; Month is Nov&lt;BR /&gt; Mon is 01&lt;BR /&gt;&lt;BR /&gt;I was expecting the value of Mon to be UNKNOWN but instead it is 01. In other words, the test condition in my if-statement is not working. &lt;BR /&gt;Does anyone know where this is going wrong? &lt;BR /&gt;&lt;BR /&gt;Many thanks and regards, &lt;BR /&gt;Preet :-)</description>
      <pubDate>Thu, 29 Nov 2001 11:04:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622014#M38930</guid>
      <dc:creator>Preet Dhillon</dc:creator>
      <dc:date>2001-11-29T11:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error with script to compare two text strings</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622015#M38931</link>
      <description>Hi Preet,&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;&lt;BR /&gt;MONTH=`date|cut -d " " -f 2`&lt;BR /&gt;if [ $MONTH = "Jan" ]; then&lt;BR /&gt;MON=01&lt;BR /&gt;else MON=UNKNOWN&lt;BR /&gt;fi&lt;BR /&gt;echo "Month is $MONTH"&lt;BR /&gt;echo "Mon is $MON"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Nov 2001 11:15:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622015#M38931</guid>
      <dc:creator>Kevin Bingham</dc:creator>
      <dc:date>2001-11-29T11:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Error with script to compare two text strings</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622016#M38932</link>
      <description>The shell needs white space between operators to recognise them...&lt;BR /&gt;&lt;BR /&gt;Change &lt;BR /&gt;&lt;BR /&gt;if test $MONTH="Jan"&lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt;if test $MONTH = "Jan"&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Thu, 29 Nov 2001 11:18:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622016#M38932</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2001-11-29T11:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Error with script to compare two text strings</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622017#M38933</link>
      <description>Try putting a space around the equal size in the test statement, i.e.:&lt;BR /&gt;&lt;BR /&gt; MONTH="Nov"&lt;BR /&gt;if test $MONTH = "Jan"&lt;BR /&gt;then&lt;BR /&gt;MON=01&lt;BR /&gt;else MON=UNKNOWN&lt;BR /&gt;fi&lt;BR /&gt;echo "Month is $MONTH"&lt;BR /&gt;echo "Mon is $MON"&lt;BR /&gt;&lt;BR /&gt;Notice the space before and after the = in the 'if test' statement.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;-Santosh&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Nov 2001 11:21:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622017#M38933</guid>
      <dc:creator>Santosh Nair_1</dc:creator>
      <dc:date>2001-11-29T11:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error with script to compare two text strings</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622018#M38934</link>
      <description>Use the following and cut the code down aswell ;)&lt;BR /&gt;&lt;BR /&gt;MONTH="Nov"&lt;BR /&gt;MON=UNKNOWN&lt;BR /&gt;[ $MONTH = "Jan" ] &amp;amp;&amp;amp; MON=01</description>
      <pubDate>Thu, 29 Nov 2001 12:18:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622018#M38934</guid>
      <dc:creator>Phil Daws_1</dc:creator>
      <dc:date>2001-11-29T12:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error with script to compare two text strings</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622019#M38935</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you can also use a case construct:&lt;BR /&gt;&lt;BR /&gt;case $MONTH in&lt;BR /&gt;Jan) MON=01;;&lt;BR /&gt;Feb) MON=02;;&lt;BR /&gt;Mar) MON=03;;&lt;BR /&gt;Apr) MON=04;;&lt;BR /&gt;May) MON=05;;&lt;BR /&gt;Jun) MON=06;;&lt;BR /&gt;Jul) MON=07;;&lt;BR /&gt;Aug) MON=08;;&lt;BR /&gt;Sep) MON=09;;&lt;BR /&gt;Oct) MON=10;;&lt;BR /&gt;Nov) MON=11;;&lt;BR /&gt;Dec) MON=12;;&lt;BR /&gt;*) MON=UNKNOWN;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 29 Nov 2001 14:12:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622019#M38935</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2001-11-29T14:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error with script to compare two text strings</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622020#M38936</link>
      <description>Hello Preet,&lt;BR /&gt;&lt;BR /&gt;the reason is the missing spaces, as all the others already told you...&lt;BR /&gt;But as an additional tip:&lt;BR /&gt;ALWAYS quote substitutions, e.g.&lt;BR /&gt;&lt;BR /&gt;if [ "$MONTH" = "Jan" ]&lt;BR /&gt;...&lt;BR /&gt;case "$MAONTH" in&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;for the simple reason that one day your variable might be unset or plain empty and then you will get an syntax error message from the shell - but with quotes your script will still work.&lt;BR /&gt;&lt;BR /&gt;Just my ???0.02,&lt;BR /&gt;Wodisch</description>
      <pubDate>Thu, 29 Nov 2001 14:38:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-with-script-to-compare-two-text-strings/m-p/2622020#M38936</guid>
      <dc:creator>Wodisch</dc:creator>
      <dc:date>2001-11-29T14:38:55Z</dc:date>
    </item>
  </channel>
</rss>

