<?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: if statement issues.... in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151211#M90654</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I will try not to make any major changes in&lt;BR /&gt;your script, although your problem can be &lt;BR /&gt;rewritten in much better ways :)&lt;BR /&gt;&lt;BR /&gt;A) There is no print statement in standard Shells.&lt;BR /&gt;&lt;BR /&gt;b) Your "if" loops were wrong.&lt;BR /&gt;&lt;BR /&gt;c) It is good to wrap $ANSWER3 in quotes so&lt;BR /&gt;if a user types nothing, you do not get an&lt;BR /&gt;error.&lt;BR /&gt;&lt;BR /&gt;echo "This is the max size your lvol can be:"&lt;BR /&gt;echo $MAXSIZE&lt;BR /&gt;echo&lt;BR /&gt;echo Do you want to max out the size of your lvol?&lt;BR /&gt;#print -n "Enter 'y' for Yes or 'n' for No :"&lt;BR /&gt;echo -n "Enter 'y' for Yes or 'n' for No :"&lt;BR /&gt;read ANSWER3&lt;BR /&gt;if [ "$ANSWER3" = "n" -o "$ANSWER3" = "N" -o "$ANSWER3" = "no" -o $"ANSWER3" = "No" ]&lt;BR /&gt;then&lt;BR /&gt;     exit&lt;BR /&gt;else&lt;BR /&gt;     continue&lt;BR /&gt;fi&lt;BR /&gt;if [ "$ANSWER3" = "y" -o "$ANSWER3" = "Y" -o "$ANSWER3" = "yes" -o "$ANSWER3" = "Yes" ]&lt;BR /&gt;  then&lt;BR /&gt;    echo&lt;BR /&gt;    echo "vxassist -g $DISKGROUP growto $LVOL $MAXSIZE"&lt;BR /&gt;    vxassist -g $DISKGROUP growto $LVOL $MAXSIZE&lt;BR /&gt;    exit&lt;BR /&gt;  else&lt;BR /&gt;    exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
    <pubDate>Wed, 27 Feb 2008 03:35:58 GMT</pubDate>
    <dc:creator>VK2COT</dc:creator>
    <dc:date>2008-02-27T03:35:58Z</dc:date>
    <item>
      <title>if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151210#M90653</link>
      <description>&lt;!--!*#--&gt;The problem I am having here is that only the 1st option is executed, no matter if I pick yes or no.  What am I doing wrong?  How can I get this working right without resorting to a case statement?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;echo "This is the max size your lvol can be:"&lt;BR /&gt;echo $MAXSIZE&lt;BR /&gt;echo&lt;BR /&gt;echo Do you want to max out the size of your lvol?&lt;BR /&gt;print -n "Enter 'y' for Yes or 'n' for No :"&lt;BR /&gt;read ANSWER3&lt;BR /&gt;if [ $ANSWER3="n" ] || [ $ANSWER3="N" ] || [ $ANSWER3="no" ] || [ $ANSWER3="No" ]&lt;BR /&gt;    then&lt;BR /&gt;     exit&lt;BR /&gt;    else&lt;BR /&gt;     continue&lt;BR /&gt;fi&lt;BR /&gt;if [ $ANSWER3="y" ] || [ $ANSWER3="Y" ] || [ $ANSWER3="yes" ] || [ $ANSWER3="Yes" ]&lt;BR /&gt;  then&lt;BR /&gt;    echo&lt;BR /&gt;    echo "vxassist -g $DISKGROUP growto $LVOL $MAXSIZE"&lt;BR /&gt;    vxassist -g $DISKGROUP growto $LVOL $MAXSIZE&lt;BR /&gt;    exit&lt;BR /&gt;  else&lt;BR /&gt;    exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------------</description>
      <pubDate>Wed, 27 Feb 2008 02:08:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151210#M90653</guid>
      <dc:creator>Patrick Ware_1</dc:creator>
      <dc:date>2008-02-27T02:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151211#M90654</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I will try not to make any major changes in&lt;BR /&gt;your script, although your problem can be &lt;BR /&gt;rewritten in much better ways :)&lt;BR /&gt;&lt;BR /&gt;A) There is no print statement in standard Shells.&lt;BR /&gt;&lt;BR /&gt;b) Your "if" loops were wrong.&lt;BR /&gt;&lt;BR /&gt;c) It is good to wrap $ANSWER3 in quotes so&lt;BR /&gt;if a user types nothing, you do not get an&lt;BR /&gt;error.&lt;BR /&gt;&lt;BR /&gt;echo "This is the max size your lvol can be:"&lt;BR /&gt;echo $MAXSIZE&lt;BR /&gt;echo&lt;BR /&gt;echo Do you want to max out the size of your lvol?&lt;BR /&gt;#print -n "Enter 'y' for Yes or 'n' for No :"&lt;BR /&gt;echo -n "Enter 'y' for Yes or 'n' for No :"&lt;BR /&gt;read ANSWER3&lt;BR /&gt;if [ "$ANSWER3" = "n" -o "$ANSWER3" = "N" -o "$ANSWER3" = "no" -o $"ANSWER3" = "No" ]&lt;BR /&gt;then&lt;BR /&gt;     exit&lt;BR /&gt;else&lt;BR /&gt;     continue&lt;BR /&gt;fi&lt;BR /&gt;if [ "$ANSWER3" = "y" -o "$ANSWER3" = "Y" -o "$ANSWER3" = "yes" -o "$ANSWER3" = "Yes" ]&lt;BR /&gt;  then&lt;BR /&gt;    echo&lt;BR /&gt;    echo "vxassist -g $DISKGROUP growto $LVOL $MAXSIZE"&lt;BR /&gt;    vxassist -g $DISKGROUP growto $LVOL $MAXSIZE&lt;BR /&gt;    exit&lt;BR /&gt;  else&lt;BR /&gt;    exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
      <pubDate>Wed, 27 Feb 2008 03:35:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151211#M90654</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2008-02-27T03:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151212#M90655</link>
      <description>Ahh, my bad typing.&lt;BR /&gt;&lt;BR /&gt;Replace the first "if" statement with:&lt;BR /&gt;&lt;BR /&gt;if [ "$ANSWER3" = "n" -o "$ANSWER3" = "N" -o "$ANSWER3" = "no" -o "$ANSWER3" = "No" ]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
      <pubDate>Wed, 27 Feb 2008 03:40:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151212#M90655</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2008-02-27T03:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151213#M90656</link>
      <description>Perfect!  Thanks for the direction!!</description>
      <pubDate>Wed, 27 Feb 2008 04:42:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151213#M90656</guid>
      <dc:creator>Patrick Ware_1</dc:creator>
      <dc:date>2008-02-27T04:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151214#M90657</link>
      <description>Hi Patrick:&lt;BR /&gt;&lt;BR /&gt;You can eliminate having to test to lowercase and uppercase replies (or MiXeD caes!) by using 'typeset -l':&lt;BR /&gt;&lt;BR /&gt;typeset -l ANSWER3&lt;BR /&gt;&lt;BR /&gt;...now, whenever your perform:&lt;BR /&gt;&lt;BR /&gt;read ANSWER3&lt;BR /&gt;&lt;BR /&gt;...the variable will contain only lowercase characters.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 27 Feb 2008 05:01:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151214#M90657</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-02-27T05:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151215#M90658</link>
      <description>You may want to consider using a case to be more structured:&lt;BR /&gt;case $ANSWER in&lt;BR /&gt;n|N|no|No|NO|NO!) exit ;;&lt;BR /&gt;y|Y|yes|Yes) ;; # fall thru&lt;BR /&gt;*) exit ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Dusan: A) There is no print statement in standard Shells.&lt;BR /&gt;&lt;BR /&gt;Sure there is.  :-) A real shell has it.  In fact I've seen people that frown on using echo and want you to use print.  But both are builtin in a real shell.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;b) Your "if" loops were wrong.&lt;BR /&gt;&lt;BR /&gt;Yes.  But if you still want to use ||:&lt;BR /&gt;if [[ "$ANSWER3" = "n" || "$ANSWER3" = "N" || "$ANSWER3" = "no" || "$ANSWER3" = "No" ]]&lt;BR /&gt;&lt;BR /&gt;&amp;gt;c) It is good to wrap $ANSWER3 in quotes&lt;BR /&gt;&lt;BR /&gt;I've seen pedantic cases where they go further to handle leading "-":&lt;BR /&gt;X"$ANSWER3" = X"n"</description>
      <pubDate>Wed, 27 Feb 2008 05:46:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151215#M90658</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-02-27T05:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151216#M90659</link>
      <description>&lt;!--!*#--&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;OK, now that things work, let's make&lt;BR /&gt;improvements.&lt;BR /&gt;&lt;BR /&gt;With all nice inputs from others, we can&lt;BR /&gt;make it a bit simpler and more efficient.&lt;BR /&gt;&lt;BR /&gt;a) You do not really need two "if"&lt;BR /&gt;statements. The small case-statement will&lt;BR /&gt;handle it safely.&lt;BR /&gt;&lt;BR /&gt;b) Since standard HP-UX Shells are not Posix shells, "print" statement is still better&lt;BR /&gt;to be left out and "echo" used instead.&lt;BR /&gt;&lt;BR /&gt;c) You can narrow down your input&lt;BR /&gt;to the first character only and then check&lt;BR /&gt;if it is "n" or "y".&lt;BR /&gt;&lt;BR /&gt;echo "This is the max size your lvol can be:"&lt;BR /&gt;echo $MAXSIZE&lt;BR /&gt;echo&lt;BR /&gt;echo Do you want to max out the size of your lvol?&lt;BR /&gt;echo -n "Enter 'y' for Yes or 'n' for No :"&lt;BR /&gt;&lt;BR /&gt;read ANS&lt;BR /&gt;if [ "$ANS" ]&lt;BR /&gt;then&lt;BR /&gt;   ANSWER3="`echo $ANS |cut -c1`"&lt;BR /&gt;   typeset ANSWER3&lt;BR /&gt;else&lt;BR /&gt;   ANSWER3=""&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;case $ANSWER3 in&lt;BR /&gt;   n*|N*) exit&lt;BR /&gt;          ;;&lt;BR /&gt;   y*|Y*) echo&lt;BR /&gt;          echo "vxassist -g $DISKGROUP growto $LVOL $MAXSIZE"&lt;BR /&gt;          vxassist -g $DISKGROUP growto $LVOL $MAXSIZE&lt;BR /&gt;          ;;&lt;BR /&gt;   *) exit ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;As you can see, many choices :)&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;VK2COT</description>
      <pubDate>Wed, 27 Feb 2008 09:34:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151216#M90659</guid>
      <dc:creator>VK2COT</dc:creator>
      <dc:date>2008-02-27T09:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151217#M90660</link>
      <description>&lt;P&gt;&amp;gt;Dusan: b) Since standard HP-UX Shells are not Posix shells, "print" statement is still better to be left out and "echo" used instead.&lt;BR /&gt;&lt;BR /&gt;You are confused only on your first point. sh IS the Posix shell (a real shell).&lt;BR /&gt;&lt;A href="http://h20000.www2.hp.com/bc/docs/support/SupportManual/c02267598/c02267598.pdf" target="_blank"&gt;http://h20000.www2.hp.com/bc/docs/support/SupportManual/c02267598/c02267598.pdf&lt;/A&gt;﻿&lt;/P&gt;</description>
      <pubDate>Sat, 17 Sep 2011 20:31:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151217#M90660</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-09-17T20:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151218#M90661</link>
      <description>Dennis...&lt;BR /&gt;&lt;BR /&gt;the linux types are pushing "dash" as *the* standard shell, and substituting c-style 'print' instead of 'echo'....&lt;BR /&gt;&lt;BR /&gt;claim it "eliminates incompatibilities" between implementations of "echo"..&lt;BR /&gt;&lt;BR /&gt;the def. shell in ubuntu is now dash, and you'd be amazed how many previously working installation scripts are now broken, at least temporarily&lt;BR /&gt;&lt;BR /&gt;then they hit real unix....and wonder where all the non-std gnu options went</description>
      <pubDate>Wed, 27 Feb 2008 15:46:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151218#M90661</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2008-02-27T15:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151219#M90662</link>
      <description>Hi Patrick:&lt;BR /&gt;&lt;BR /&gt;...and while we are discussing favorite shells, remember NEVER change root's default shell from '/sbin/sh' to anything else!&lt;BR /&gt;&lt;BR /&gt;The '/sbin/sh' is a statically-linked POSIX shell that does not need any libraries found in '/usr'.  Thus, in single-user mode it is capable of doing everything it needs.&lt;BR /&gt;&lt;BR /&gt;For most users, the POSIX shell which uses dynamically linked libraries is preferred.  This is '/usr/bin/sh'.  This improves the overall memory footprint somewhat, since multiple instantiations can share some code.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 27 Feb 2008 15:56:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151219#M90662</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-02-27T15:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151220#M90663</link>
      <description>&amp;gt;JRF: This is /usr/bin/sh. This improves the overall memory footprint somewhat, since multiple instantiations can share some code.&lt;BR /&gt;&lt;BR /&gt;You'll find that if you get a bean counter to add up the numbers, it probably doesn't.&lt;BR /&gt;The size of a process is 1 X the text size.  And N X the data size.  You'll find that the N X D far out weighs the 1 X T vs 1 X T' savings for the shared version.&lt;BR /&gt;&lt;BR /&gt;That said, you should still use /usr/bin/sh so you can use fancy smancy locales.&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Feb 2008 00:34:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151220#M90663</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-02-28T00:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: if statement issues....</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151221#M90664</link>
      <description>&lt;!--!*#--&gt;Patrick,&lt;BR /&gt;&lt;BR /&gt;Actually, do your really need to test for both a 'y' and an 'n'?  Aren't you really interested in only one answer, the 'y' one?&lt;BR /&gt;&lt;BR /&gt;I have a small function I use any time I need this functionality.  Here it it:&lt;BR /&gt;&lt;BR /&gt;ask_yn() {&lt;BR /&gt;  echo "Enter [y] to continue: \c"&lt;BR /&gt;  read ans&lt;BR /&gt;  if [ -z "$ans" -o "$ans" != "y" ] ; then&lt;BR /&gt;    echo "Aborting"&lt;BR /&gt;    exit&lt;BR /&gt;  fi&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;In other words, I really don't care if the answer is anything other than 'y', becuase I'm bailing out if it's not.  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Yes, you can do all the checks to see if it's cap, whole word, etc. but I'm just illustrating a point.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Mark</description>
      <pubDate>Fri, 29 Feb 2008 15:41:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-statement-issues/m-p/4151221#M90664</guid>
      <dc:creator>Mark Ellzey</dc:creator>
      <dc:date>2008-02-29T15:41:38Z</dc:date>
    </item>
  </channel>
</rss>

