<?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>Operating System - HP-UX의 주제 Re: Shell Programming</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002602#M126830</link>
    <description>Hi!&lt;BR /&gt;&lt;BR /&gt;Try the following:&lt;BR /&gt;&lt;BR /&gt;if [ "$PIE" != "apple" -o "$PIE" != "cherry" -o "$PIE" != "pumpkin" ]&lt;BR /&gt;then &lt;BR /&gt;echo "Not good"&lt;BR /&gt;else &lt;BR /&gt;echo "Goood!" &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Dario</description>
    <pubDate>Thu, 19 Jun 2003 17:00:59 GMT</pubDate>
    <dc:creator>Dario_1</dc:creator>
    <dc:date>2003-06-19T17:00:59Z</dc:date>
    <item>
      <title>Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002598#M126826</link>
      <description>Hello all...&lt;BR /&gt;I am attempting to ensure that the value of a given variable matches one of three strings.&lt;BR /&gt;Basically it's &lt;BR /&gt;if "$PIE" does not equal "cherry" "apple" or "pumpkin" then i want to exit the loop and print the usage statement. If it does match then i want the loop to continue.  &lt;BR /&gt;My syntax is as follows but does not work, I think is may be an -0 or || compund expression issue.... Thanks.&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;PIE=cherry&lt;BR /&gt;&lt;BR /&gt;if [ "$PIE" != [ "apple" || "cherry" || "pumpkin" ]]&lt;BR /&gt;then&lt;BR /&gt;        echo "\n****Valid names are apple,cherry or pumpkin!\n" ; exit 1&lt;BR /&gt;else&lt;BR /&gt;        echo "\n****Name is valid!\n"&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for the help....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 16:43:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002598#M126826</guid>
      <dc:creator>Scott E Smith</dc:creator>
      <dc:date>2003-06-19T16:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002599#M126827</link>
      <description>Try:&lt;BR /&gt;&lt;BR /&gt;case $PIE in&lt;BR /&gt;  apple) echo "\n****Name is valid!\n" ;;&lt;BR /&gt;  cherry) echo "\n****Name is valid!\n" ;;&lt;BR /&gt;  pumpkin) echo "\n****Name is valid!\n" ;;&lt;BR /&gt;  *) echo "\n****Valid names are apple,cherry or pumpkin!\n" ; exit 1 ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;&lt;REST of="" code=""&gt;&lt;/REST&gt;</description>
      <pubDate>Thu, 19 Jun 2003 16:48:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002599#M126827</guid>
      <dc:creator>David Child_1</dc:creator>
      <dc:date>2003-06-19T16:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002600#M126828</link>
      <description>Hi Scott:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;# if [ "$PIE" != "apple" -a "$PIE" != "cherry" -a "$PIE" != "pumpkin" ]; then&lt;BR /&gt;&amp;gt; echo "bad pie!"&lt;BR /&gt;&amp;gt; else&lt;BR /&gt;&amp;gt; echo "yummy pie!"&lt;BR /&gt;&amp;gt; fi&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 19 Jun 2003 16:52:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002600#M126828</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-06-19T16:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002601#M126829</link>
      <description>I don't think that "if" works that way.&lt;BR /&gt;&lt;BR /&gt;I would probably do that with "case":&lt;BR /&gt;&lt;BR /&gt;case  $PIE in&lt;BR /&gt;                    pumpkin)    print "Thank you.";;&lt;BR /&gt;                    cherry | apple)    print "Gracias.";;&lt;BR /&gt;                    *)          print "Wrong answer.  Sorry..."&lt;BR /&gt;exit;;&lt;BR /&gt;                  esac&lt;BR /&gt;#  Process pie&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;statements...&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 16:52:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002601#M126829</guid>
      <dc:creator>Stuart Abramson_2</dc:creator>
      <dc:date>2003-06-19T16:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002602#M126830</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;Try the following:&lt;BR /&gt;&lt;BR /&gt;if [ "$PIE" != "apple" -o "$PIE" != "cherry" -o "$PIE" != "pumpkin" ]&lt;BR /&gt;then &lt;BR /&gt;echo "Not good"&lt;BR /&gt;else &lt;BR /&gt;echo "Goood!" &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Dario</description>
      <pubDate>Thu, 19 Jun 2003 17:00:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002602#M126830</guid>
      <dc:creator>Dario_1</dc:creator>
      <dc:date>2003-06-19T17:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002603#M126831</link>
      <description>You can also do this:&lt;BR /&gt;&lt;BR /&gt;if [ $PIE = apple -o $PIE = cherry -o $PIE = pumpkin ]&lt;BR /&gt;then &lt;BR /&gt;echo true&lt;BR /&gt;else&lt;BR /&gt;echo wrong&lt;BR /&gt;fi</description>
      <pubDate>Thu, 19 Jun 2003 17:01:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002603#M126831</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-06-19T17:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002604#M126832</link>
      <description>Scott,&lt;BR /&gt;this is a logic problem.&lt;BR /&gt;The logic says&lt;BR /&gt;"If $PIE is not equal to "apple" OR if $PIE is not equal to "cherry" OR if $PIE is not equal to "pumpkin" &lt;BR /&gt;then&lt;BR /&gt;echo "\n****Valid names are apple,cherry or pumpkin!\n" ; exit 1&lt;BR /&gt;else ...&lt;BR /&gt;&lt;BR /&gt;As written, $PIE is not equal to "apple" so the test is TRUE and because it is TRUE, the shell will not evaluate the rest of the tests and it executes the first echo command.&lt;BR /&gt;The way to do this is by using an AND operator.&lt;BR /&gt;&lt;BR /&gt;Here is a version that will do what you want.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;PIE=cherry&lt;BR /&gt;&lt;BR /&gt;if [ "$PIE" !=  "apple" -a $PIE != "cherry" -a $PIE != "pumpkin" ]&lt;BR /&gt;then&lt;BR /&gt;echo "\n****Valid names are apple,cherry or pumpkin!\n" ; exit 1&lt;BR /&gt;else&lt;BR /&gt;echo "\n****Name is valid!\n"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Michael.</description>
      <pubDate>Thu, 19 Jun 2003 17:11:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002604#M126832</guid>
      <dc:creator>Michael Kelly_5</dc:creator>
      <dc:date>2003-06-19T17:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002605#M126833</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Do *not* [no pun intended] use the 'or' operator [ -o ] with negatated equality checks.  You will not achieve the desired outcome.  Try this:&lt;BR /&gt;&lt;BR /&gt;# PIE=apple&lt;BR /&gt;&lt;BR /&gt;# [ "$PIE" != "apple" -a "$PIE" != "cherry" -a "$PIE" != "pumpkin" ] &amp;amp;&amp;amp; echo BAD_PIE!&lt;BR /&gt;&lt;BR /&gt;...now change '-a' to '-o':&lt;BR /&gt;&lt;BR /&gt;[ "$PIE" != "apple" -o "$PIE" != "cherry" -o "$PIE" != "pumpkin" ] &amp;amp;&amp;amp; echo BAD_PIE!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 19 Jun 2003 17:18:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002605#M126833</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-06-19T17:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002606#M126834</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;if [ "$PIE" != "apple"] || [ $"PIE" != "cherry" ] || [ "$PIE" != "pumpkin" ] ;&lt;BR /&gt;then&lt;BR /&gt;echo "Usage: `basename $0` {whatever options}"&lt;BR /&gt;exit&lt;BR /&gt;else&lt;BR /&gt;#whatever commands you wnat&lt;BR /&gt;fi</description>
      <pubDate>Thu, 19 Jun 2003 17:25:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002606#M126834</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-06-19T17:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002607#M126835</link>
      <description>looking at everyone's replies... isn't it interesting how many differnt approaches there are as well as the ones we choose to take?  &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 17:29:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002607#M126835</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-06-19T17:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002608#M126836</link>
      <description>Why not just got for a burger? :)&lt;BR /&gt;&lt;BR /&gt;Null points pse. Ian</description>
      <pubDate>Thu, 19 Jun 2003 17:38:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002608#M126836</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2003-06-19T17:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002609#M126837</link>
      <description>You guys all kick A$$..... Thanks a bunch.   Ian you get points for humor...</description>
      <pubDate>Thu, 19 Jun 2003 17:44:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002609#M126837</guid>
      <dc:creator>Scott E Smith</dc:creator>
      <dc:date>2003-06-19T17:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002610#M126838</link>
      <description>Hi John M:&lt;BR /&gt;&lt;BR /&gt;Your example should be use "&amp;amp;&amp;amp;" not "||" as:&lt;BR /&gt;&lt;BR /&gt;# if [ "$PIE" != "apple" ] &amp;amp;&amp;amp; [ "$PIE" != "cherry" ] &amp;amp;&amp;amp; [ "$PIE" != "pumpkin" ]&lt;BR /&gt;&amp;gt; then&lt;BR /&gt;&amp;gt; echo BAD_PIE&lt;BR /&gt;&amp;gt; else&lt;BR /&gt;&amp;gt; echo GOOD_PIE&lt;BR /&gt;&amp;gt; fi&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 17:45:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002610#M126838</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-06-19T17:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002611#M126839</link>
      <description>James:&lt;BR /&gt;&lt;BR /&gt;Thank you for shaking my head. I used your approach (trying to avoid the typing) but using the -o option and forgot to remove the exclamation (!). You are totally correct....Thank you for the correction.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Dario</description>
      <pubDate>Thu, 19 Jun 2003 17:58:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002611#M126839</guid>
      <dc:creator>Dario_1</dc:creator>
      <dc:date>2003-06-19T17:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002612#M126840</link>
      <description>James,&lt;BR /&gt;   No - my example is correct.  He's asking if pie does not equal apple OR pumpkin - hence the || operator.  Whereas if he was checking to see if pie does not equal applor AND pumpkin then i'd use the &amp;amp;&amp;amp;</description>
      <pubDate>Wed, 25 Jun 2003 11:27:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002612#M126840</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-06-25T11:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002613#M126841</link>
      <description>Scott,&lt;BR /&gt;&lt;BR /&gt;use the shell's built in test operator.&lt;BR /&gt;&lt;BR /&gt;the next if statement calls an external test operator;&lt;BR /&gt;&lt;BR /&gt;if [ $PIE = xxx ]; then blabla&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for faster processing use the internal test operator&lt;BR /&gt;&lt;BR /&gt;if [[ "$PIE" != "apple" -a "$PIE" != "cherry" -a "$PIE" != "pumpkin" ]]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Jun 2003 11:39:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002613#M126841</guid>
      <dc:creator>Donny Jekels</dc:creator>
      <dc:date>2003-06-25T11:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002614#M126842</link>
      <description>Case-insensitive example:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;PIE=$1&lt;BR /&gt;if echo $PIE | egrep -i -q -e "^apple$|^cherry$|^pumpkin$"&lt;BR /&gt;then&lt;BR /&gt; echo "$PIE pie; umm-umm-good"&lt;BR /&gt;else&lt;BR /&gt; echo "I don't know about $PIE pie"&lt;BR /&gt;fi</description>
      <pubDate>Wed, 25 Jun 2003 12:00:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002614#M126842</guid>
      <dc:creator>Bill Douglass</dc:creator>
      <dc:date>2003-06-25T12:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002615#M126843</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This variant uses 'select' : you have to choose a number instead of a fruit. See 'select' in man sh-posix.&lt;BR /&gt;&lt;BR /&gt;Regards.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;export PS3="Enter Fruit "&lt;BR /&gt;select VAR in apple cherry pumpkin&lt;BR /&gt;do&lt;BR /&gt;  [ -z "$VAR" ] &amp;amp;&amp;amp;&lt;BR /&gt;  {&lt;BR /&gt;    echo "$REPLY is note a correct choice, exiting ..."&lt;BR /&gt;    break&lt;BR /&gt;  }&lt;BR /&gt;  echo "You've chosen a $VAR"&lt;BR /&gt;done</description>
      <pubDate>Wed, 25 Jun 2003 12:08:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002615#M126843</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2003-06-25T12:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Programming</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002616#M126844</link>
      <description>The best solution, as pointed out by others is to use the case statement.  But since you also asked for other solutions, here's a wierd one:&lt;BR /&gt;&lt;BR /&gt;echo $PIE|egrep '^(apple|cherry|pumpkin)' 2&amp;gt;&amp;amp;1 &amp;gt; /dev/null&lt;BR /&gt;if test "$?" ne "0"&lt;BR /&gt;then&lt;BR /&gt;     echo "ICKYPOO!!! I don't like $PIE pie!"&lt;BR /&gt;else&lt;BR /&gt;     echo "Yummmm: a $PIE pie!"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Chris&amp;lt;--regexps are your friend......&lt;BR /&gt;(if sometimes a very confusing friend)</description>
      <pubDate>Wed, 25 Jun 2003 13:19:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-programming/m-p/3002616#M126844</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2003-06-25T13:19:53Z</dc:date>
    </item>
  </channel>
</rss>

