<?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: Problems with or operator in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526805#M651771</link>
    <description>uh...that should have read:&lt;BR /&gt;&lt;BR /&gt;"You can make other cases by negating the logic to force it thru the "then" CLAUSES, instead of the "else" clauses, but I'll not muddy the waters further</description>
    <pubDate>Tue, 03 Nov 2009 21:11:16 GMT</pubDate>
    <dc:creator>OldSchool</dc:creator>
    <dc:date>2009-11-03T21:11:16Z</dc:date>
    <item>
      <title>Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526799#M651765</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am new to unix and trying to create a shell script.&lt;BR /&gt;&lt;BR /&gt;I have problems with the or operator in if condition.&lt;BR /&gt;&lt;BR /&gt;if [ $1 != Trail ] -o [ $1 != Image ]&lt;BR /&gt;&lt;BR /&gt;Is that a valid syntex for ksh ? &lt;BR /&gt;The condition checks Trail but not for Image. I also tried with || but doent work.&lt;BR /&gt;&lt;BR /&gt;Please let me know&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Nov 2009 17:10:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526799#M651765</guid>
      <dc:creator>suneeth</dc:creator>
      <dc:date>2009-11-03T17:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526800#M651766</link>
      <description>Do this instead:&lt;BR /&gt;&lt;BR /&gt;if [ $1 != Trail -o $1 != Image ]</description>
      <pubDate>Tue, 03 Nov 2009 17:24:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526800#M651766</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2009-11-03T17:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526801#M651767</link>
      <description>Something appears wrong with the logic as well.  Shouldn't that *always* come out a true?&lt;BR /&gt;&lt;BR /&gt;if $1=Trial then the !=Image is true, if $1=Image the !=Trail is true, if it's anything else they both return true....&lt;BR /&gt;&lt;BR /&gt;or do I need more coffee????</description>
      <pubDate>Tue, 03 Nov 2009 18:43:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526801#M651767</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-11-03T18:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526802#M651768</link>
      <description>&amp;gt;&amp;gt;or do I need more coffee????&lt;BR /&gt;&lt;BR /&gt;No OldSchool, you've got it correct as far as I can tell.  Once I looked at it closer I realized the same as you.</description>
      <pubDate>Tue, 03 Nov 2009 19:01:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526802#M651768</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2009-11-03T19:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526803#M651769</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You want an 'and' in this case:&lt;BR /&gt;&lt;BR /&gt;# if [ "$1" != "Trail" -a "$1" != "Image" ]; then&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Double quoting your variables also prevents syntax errors if they are ever undefined, too.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 03 Nov 2009 19:43:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526803#M651769</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-11-03T19:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526804#M651770</link>
      <description>"You want an 'and' in this case:&lt;BR /&gt;&lt;BR /&gt;# if [ "$1" != "Trail" -a "$1" != "Image" ]; then"&lt;BR /&gt;&lt;BR /&gt;Well....maybe.&lt;BR /&gt;&lt;BR /&gt;You can take some actions / set of actions if $1 is not "Trail" and is not "Image", else do something else (optional).  &lt;BR /&gt;&lt;BR /&gt;This is the case with the test above. Had $1 been "Junk" it would have fallen thru / hit the else clause if present.&lt;BR /&gt;&lt;BR /&gt;Another possibility is: you can take some actions / set of actions if $1 is *either* "Trail" or "Image", else do something else. in that case "if [ "$1" = "Trail" -o "$1 = "Image" ] ; then" would be appropriate&lt;BR /&gt;&lt;BR /&gt;Depends on the OPs intent was.  Since the basic logic posted was wrong, then either could apply, although I suspect that JRF has right.&lt;BR /&gt;&lt;BR /&gt;You can make other cases by negating the logic to force it thru the "then" else, instead of the "else" clauses, but I'll not muddy the waters further&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Nov 2009 20:50:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526804#M651770</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-11-03T20:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526805#M651771</link>
      <description>uh...that should have read:&lt;BR /&gt;&lt;BR /&gt;"You can make other cases by negating the logic to force it thru the "then" CLAUSES, instead of the "else" clauses, but I'll not muddy the waters further</description>
      <pubDate>Tue, 03 Nov 2009 21:11:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526805#M651771</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-11-03T21:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526806#M651772</link>
      <description>&amp;gt;I also tried with || but doesn't work.&lt;BR /&gt;&lt;BR /&gt;If you use [[ ]], you can use || and &amp;amp;&amp;amp;.&lt;BR /&gt;if [[ "$1" != Trail &amp;amp;&amp;amp; "$1" != Image ]]; then&lt;BR /&gt;&lt;BR /&gt;You can also use the shell's &amp;amp;&amp;amp; or ||:&lt;BR /&gt;[ "$1" != Trail ] &amp;amp;&amp;amp; [ "$1" != Image ] &amp;amp;&amp;amp; some-command&lt;BR /&gt;&lt;BR /&gt;If you have just numeric values, you can C syntax:&lt;BR /&gt;if (( var1 != 99 &amp;amp;&amp;amp; var1 != 88 )); then</description>
      <pubDate>Tue, 03 Nov 2009 23:53:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526806#M651772</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-03T23:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526807#M651773</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Happy to see many replies overnight.&lt;BR /&gt;Anyway. Thanks for the replies&lt;BR /&gt;&lt;BR /&gt;This works finally..&lt;BR /&gt;if [[ "$1" != Trail &amp;amp;&amp;amp; "$1" != Image ]]&lt;BR /&gt;&lt;BR /&gt;The intention was I want the parameter either Trail or Image. If it is trail do something or Image do something. I thought `and` will always check both conditions.&lt;BR /&gt;&lt;BR /&gt;I tried all the above solutions but getting error. However still -a should work on strings. What is the syntax using the -a? I tried all the combinations.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 04 Nov 2009 09:03:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526807#M651773</guid>
      <dc:creator>suneeth</dc:creator>
      <dc:date>2009-11-04T09:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526808#M651774</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I thought AND will always check both conditions.&lt;BR /&gt;&lt;BR /&gt;Not if the first is false.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I tried all the above solutions but getting error.&lt;BR /&gt;&lt;BR /&gt;What's your error?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;However still -a should work on strings.&lt;BR /&gt;&lt;BR /&gt;Yes -a works on boolean conditions.&lt;BR /&gt;If $1 isn't Trail nor Image, it echoes bad #.&lt;BR /&gt;if [ "$1" != "Trail" -a "$1" != "Image" ]; then&lt;BR /&gt;   echo "bad 1"&lt;BR /&gt;fi&lt;BR /&gt;if [[ "$1" != Trail &amp;amp;&amp;amp; "$1" != Image ]]; then&lt;BR /&gt;   echo "bad 2"&lt;BR /&gt;fi&lt;BR /&gt;[ "$1" != Trail ] &amp;amp;&amp;amp; [ "$1" != Image ] &amp;amp;&amp;amp; echo "bad 3"&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Nov 2009 10:21:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526808#M651774</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-04T10:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526809#M651775</link>
      <description>Understand now.&lt;BR /&gt;&lt;BR /&gt;Getting Syntax error at line 11 : `-a' is not expected for the below code&lt;BR /&gt;&lt;BR /&gt;if [ "$1" != "Trail" -a "$1" != "Image" ]; &lt;BR /&gt;if [[ "$1" != Trail &amp;amp;&amp;amp; "$1" != Image ]]; &lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Suneeth</description>
      <pubDate>Wed, 04 Nov 2009 11:34:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526809#M651775</guid>
      <dc:creator>suneeth</dc:creator>
      <dc:date>2009-11-04T11:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526810#M651776</link>
      <description>Sorry Dennis,&lt;BR /&gt;&lt;BR /&gt;All of them are working. I missed to take a comment on one of the condition.&lt;BR /&gt;&lt;BR /&gt;Thanks for all.</description>
      <pubDate>Wed, 04 Nov 2009 11:41:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526810#M651776</guid>
      <dc:creator>suneeth</dc:creator>
      <dc:date>2009-11-04T11:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526811#M651777</link>
      <description>"This works finally..&lt;BR /&gt;&lt;BR /&gt;if [[ "$1" != Trail -a "$1" != Image ]]&lt;BR /&gt;&lt;BR /&gt;The intention was I want the parameter either Trail or Image. If it is trail do something or Image do something. I thought `and` will always check both conditions."&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;uh... in that case, I'd have thought something like&lt;BR /&gt;&lt;BR /&gt;if [[ "$1" = Trail -o "$1" = Image ]]&lt;BR /&gt;&lt;BR /&gt;would have been more appropriate, as you seem to be stating you want $1 to be either Trail or Image.&lt;BR /&gt;&lt;BR /&gt;The test you posted will NOT run anything if $1 is "Trail" or "Image" but would run if $1 were, say, "Junk"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Nov 2009 13:54:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526811#M651777</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-11-04T13:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526812#M651778</link>
      <description>here's Dennis' test case modified to match the stated goal of:&lt;BR /&gt;&lt;BR /&gt;"The intention was I want the parameter either Trail or Image. If it is trail do something or Image do something. I thought `and` will always check both conditions."&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#   if $1 is Trail or Image, it echoes found #.&lt;BR /&gt;echo $1&lt;BR /&gt;if [ "$1" = "Trail" -o "$1" = "Image" ]; then&lt;BR /&gt;   echo "found 1"&lt;BR /&gt;fi&lt;BR /&gt;if [[ "$1" = Trail || "$1" = Image ]]; then&lt;BR /&gt;   echo "found 2"&lt;BR /&gt;fi&lt;BR /&gt;[ "$1" = Trail ] || [ "$1" = Image ] &amp;amp;&amp;amp; echo "found 3"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;one of the many answers above should match what you are attempting to do.  But since you state one case, then choose the logic for the other, it's really tough to tell what the heck you really want&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Nov 2009 14:08:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526812#M651778</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-11-04T14:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526813#M651779</link>
      <description>uh... in that case, I'd have thought something like&lt;BR /&gt;&lt;BR /&gt;if [[ "$1" = Trail -o "$1" = Image ]]&lt;BR /&gt;&lt;BR /&gt;would have been more appropriate, as you seem to be stating you want $1 to be either Trail or Image.&lt;BR /&gt;&lt;BR /&gt;The test you posted will NOT run anything if $1 is "Trail" or "Image" but would run if $1 were, say, "Junk"&lt;BR /&gt;-------------------------------&lt;BR /&gt;&lt;BR /&gt;This is where i used my condition. Did i construct the code badly ?&lt;BR /&gt;&lt;BR /&gt;if [ "$1" != "Trail" -a "$1" != "Image" ]; then&lt;BR /&gt;   echo "Check the case"&lt;BR /&gt;   exit&lt;BR /&gt;fi&lt;BR /&gt;#Then I start with statements for the parameter&lt;BR /&gt;while [ $1 == Trail ]&lt;BR /&gt;do&lt;BR /&gt;&lt;STATEMENTS&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;while [ $1 == Image ]&lt;BR /&gt;do&lt;BR /&gt;&lt;STATEMENTS&gt;&lt;BR /&gt;done&lt;/STATEMENTS&gt;&lt;/STATEMENTS&gt;</description>
      <pubDate>Thu, 05 Nov 2009 09:16:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526813#M651779</guid>
      <dc:creator>suneeth</dc:creator>
      <dc:date>2009-11-05T09:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526814#M651780</link>
      <description>&lt;!--!*#--&gt;&amp;gt;Did I construct the code badly?&lt;BR /&gt;if [ "$1" != "Trail" -a "$1" != "Image" ]; then&lt;BR /&gt;   echo "Check the case"&lt;BR /&gt;   exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;This seems fine.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;#Then I start with statements for the parameter&lt;BR /&gt;while [ "$1" == Trail ]; do&lt;BR /&gt;&lt;BR /&gt;I'm not sure why you want a while, instead of just an if.  Do you use shift to get the next parm?&lt;BR /&gt;&lt;BR /&gt;You may want to use a case:&lt;BR /&gt;&lt;BR /&gt;case "$1" in&lt;BR /&gt;Trail) ... ;;&lt;BR /&gt;Image) ... ;;&lt;BR /&gt;*)  echo "Check the case"&lt;BR /&gt;    exit&lt;BR /&gt;    ;;&lt;BR /&gt;esac</description>
      <pubDate>Thu, 05 Nov 2009 10:26:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526814#M651780</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-05T10:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526815#M651781</link>
      <description>Thanks a lot. &lt;BR /&gt;There is no loop in my code hence case is the right one.&lt;BR /&gt;&lt;BR /&gt;I can cover this in if, but I will have some more conditions to check and I found this will be easier.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Nov 2009 14:37:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526815#M651781</guid>
      <dc:creator>suneeth</dc:creator>
      <dc:date>2009-11-05T14:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526816#M651782</link>
      <description>Suneeth,&lt;BR /&gt;&lt;BR /&gt;My confusion revolved around your statement(s) like:&lt;BR /&gt;&lt;BR /&gt;"The intention was I want the parameter either Trail or Image. If it is trail do something or Image do something. I thought `and` will always check both conditions."&lt;BR /&gt;&lt;BR /&gt;-AND- the illustrated "IF" test&lt;BR /&gt;&lt;BR /&gt;if [ "$1" != "Trail" -a "$1" != "Image" ]; then&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;After seeing your code snippet, I'd have said that your intention was to check if $1 was either "Trail" or "Image", and stop if not.  This became clear when you posted some addtional code.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"if [ "$1" != "Trail" -a "$1" != "Image" ]; then&lt;BR /&gt;   echo "Check the case"&lt;BR /&gt;   exit&lt;BR /&gt;fi"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Actual code posted seems to be just fine.  As Dennis noted, "case" may be a more elegant solution, or it have been written as series of if/elseif/elseif...statements.&lt;BR /&gt;&lt;BR /&gt;In any event, sorry for the confusion.</description>
      <pubDate>Thu, 05 Nov 2009 15:53:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526816#M651782</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-11-05T15:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with or operator</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526817#M651783</link>
      <description>Thanks for your comments.&lt;BR /&gt;&lt;BR /&gt;As i stuck with If syntax i just want to know the whats issue is. As you said its always better to give more information instead of pasting it a single line code.&lt;BR /&gt;&lt;BR /&gt;This will help others to give thier inputs correctly.</description>
      <pubDate>Fri, 06 Nov 2009 08:54:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-or-operator/m-p/4526817#M651783</guid>
      <dc:creator>suneeth</dc:creator>
      <dc:date>2009-11-06T08:54:23Z</dc:date>
    </item>
  </channel>
</rss>

