<?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: Looping a ksh script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002398#M718602</link>
    <description>Hi CHris:&lt;BR /&gt;&lt;BR /&gt;Here's one way:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -l REPLY&lt;BR /&gt;while [ "${REPLY}" != q ]&lt;BR /&gt;do&lt;BR /&gt;  echo "Choose your poison..."&lt;BR /&gt;  read REPLY&lt;BR /&gt;  [ "${REPLY}" = q ] &amp;amp;&amp;amp; continue &lt;BR /&gt;  echo "looping"&lt;BR /&gt;done&lt;BR /&gt;echo "exiting now"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;Note the use of the 'typeset' to declare that automatic translation to lowercase characters should be made for any REPLY.  This makes' testing for responses short and easy -- no convern for uppercase versus lowercase or mixed case.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Thu, 19 Jun 2003 13:50:26 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2003-06-19T13:50:26Z</dc:date>
    <item>
      <title>Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002395#M718599</link>
      <description>I know this will be easy for some of you ...&lt;BR /&gt;&lt;BR /&gt;I have created a login termination script.  I want to continue looping this script until I type q on the command line. I need to run it manually (policy) and check for login/ids in my script.&lt;BR /&gt;&lt;BR /&gt;How can I create a basic loop to start and return to the beginning after completing each process. &lt;BR /&gt;&lt;BR /&gt;More explaination:&lt;BR /&gt;&lt;BR /&gt;while (I input something)&lt;BR /&gt;run my script&lt;BR /&gt;go back to top until I input "q".&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Thu, 19 Jun 2003 13:42:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002395#M718599</guid>
      <dc:creator>Christopher Hildrum_1</dc:creator>
      <dc:date>2003-06-19T13:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002396#M718600</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;try this:&lt;BR /&gt;&lt;BR /&gt;while true;&lt;BR /&gt;do&lt;BR /&gt;  your commands here;&lt;BR /&gt;done;&lt;BR /&gt;&lt;BR /&gt;Use Control+C to stop the loop.&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Thu, 19 Jun 2003 13:48:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002396#M718600</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-06-19T13:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002397#M718601</link>
      <description>Why don't you do something like this : &lt;BR /&gt;&lt;BR /&gt;while [ 1 ]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;   run script&lt;BR /&gt;   echo "Quit (q) ? "&lt;BR /&gt;   read key_stroke&lt;BR /&gt;&lt;BR /&gt;   if [ "$key_stroke" = "q" ]&lt;BR /&gt;   then break&lt;BR /&gt;   fi&lt;BR /&gt;done</description>
      <pubDate>Thu, 19 Jun 2003 13:48:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002397#M718601</guid>
      <dc:creator>Marco Santerre</dc:creator>
      <dc:date>2003-06-19T13:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002398#M718602</link>
      <description>Hi CHris:&lt;BR /&gt;&lt;BR /&gt;Here's one way:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -l REPLY&lt;BR /&gt;while [ "${REPLY}" != q ]&lt;BR /&gt;do&lt;BR /&gt;  echo "Choose your poison..."&lt;BR /&gt;  read REPLY&lt;BR /&gt;  [ "${REPLY}" = q ] &amp;amp;&amp;amp; continue &lt;BR /&gt;  echo "looping"&lt;BR /&gt;done&lt;BR /&gt;echo "exiting now"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;Note the use of the 'typeset' to declare that automatic translation to lowercase characters should be made for any REPLY.  This makes' testing for responses short and easy -- no convern for uppercase versus lowercase or mixed case.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 19 Jun 2003 13:50:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002398#M718602</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-06-19T13:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002399#M718603</link>
      <description>FILE=/etc/passwd&lt;BR /&gt;TEST=103&lt;BR /&gt;LOGFILE=$HOME/logfile&lt;BR /&gt;&amp;gt;$LOGFILE&lt;BR /&gt;&lt;BR /&gt;cat $FILE | while read a b c d e f g&lt;BR /&gt;do&lt;BR /&gt;   if [[ $d=$TEST ]]&lt;BR /&gt;   then&lt;BR /&gt;      break&lt;BR /&gt;   elseif&lt;BR /&gt;      continue&lt;BR /&gt;   fi&lt;BR /&gt;done &amp;gt;&amp;gt; $LOGFILE</description>
      <pubDate>Thu, 19 Jun 2003 13:59:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002399#M718603</guid>
      <dc:creator>Michael Steele_2</dc:creator>
      <dc:date>2003-06-19T13:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002400#M718604</link>
      <description>Thanks you all -&lt;BR /&gt;&lt;BR /&gt;I like the different takes on each issue - I will probably use them all in one way or another down the road.  &lt;BR /&gt;&lt;BR /&gt;michael - I was looking for the "continue"!.&lt;BR /&gt;&lt;BR /&gt;How simple!&lt;BR /&gt;&lt;BR /&gt;Thanks -&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 14:03:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002400#M718604</guid>
      <dc:creator>Christopher Hildrum_1</dc:creator>
      <dc:date>2003-06-19T14:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002401#M718605</link>
      <description>You may take a look at this loop:&lt;BR /&gt;&lt;BR /&gt; while : ;&lt;BR /&gt; do&lt;BR /&gt;  echo "Display Menu"&lt;BR /&gt; resp=*&lt;BR /&gt;        read resp&lt;BR /&gt;        case $resp in &lt;BR /&gt; [M,m])&lt;BR /&gt;   cmd&lt;BR /&gt; ;;&lt;BR /&gt;&lt;BR /&gt;        [q,Q])&lt;BR /&gt;        echo "$program: $exit_code"&lt;BR /&gt;        exit 0 &lt;BR /&gt;        ;;&lt;BR /&gt;&lt;BR /&gt;        *)&lt;BR /&gt;          echo Invalid Responce&lt;BR /&gt;    sleep 1&lt;BR /&gt;        ;;&lt;BR /&gt;        esac&lt;BR /&gt; done</description>
      <pubDate>Thu, 19 Jun 2003 14:06:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002401#M718605</guid>
      <dc:creator>twang</dc:creator>
      <dc:date>2003-06-19T14:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002402#M718606</link>
      <description>Let me add something else to this one for you:&lt;BR /&gt;&lt;BR /&gt;I am entering a UID and searching a local file that contains all UIDs,etc:&lt;BR /&gt;&lt;BR /&gt;Top part of script:&lt;BR /&gt;#########################&lt;BR /&gt;print -n 'User ID to lock ?\n'&lt;BR /&gt;        read USER&lt;BR /&gt;if [[ `/software/master/find_uid.sh "$USER:"` = "" ]];then&lt;BR /&gt;        print "No accounts available"&lt;BR /&gt;        return&lt;BR /&gt;        else&lt;BR /&gt;        continue&lt;BR /&gt;fi&lt;BR /&gt;#################&lt;BR /&gt;How do I return to re-input a new UID if there is no information in my file?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks again !&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 14:13:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002402#M718606</guid>
      <dc:creator>Christopher Hildrum_1</dc:creator>
      <dc:date>2003-06-19T14:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002403#M718607</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;"continue" will do it!&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Thu, 19 Jun 2003 14:20:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002403#M718607</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-06-19T14:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002404#M718608</link>
      <description>Hai -&lt;BR /&gt;&lt;BR /&gt;continue continues moving through the script - I need to replace the "return" with something that will "start the script over or re-enter the UID.&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 14:22:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002404#M718608</guid>
      <dc:creator>Christopher Hildrum_1</dc:creator>
      <dc:date>2003-06-19T14:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002405#M718609</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;I modified your part to become:&lt;BR /&gt;&lt;BR /&gt;while true;&lt;BR /&gt;do&lt;BR /&gt;print -n 'User ID to lock ?\n' &lt;BR /&gt;read USER &lt;BR /&gt;if [[ `/software/master/find_uid.sh "$USER:"` = "" ]];then &lt;BR /&gt;print "No accounts available" &lt;BR /&gt;continue&lt;BR /&gt;else &lt;BR /&gt;break&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 14:35:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002405#M718609</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-06-19T14:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002406#M718610</link>
      <description>RETURN=""&lt;BR /&gt;while [ test $RETURN != "yes" ] &lt;BR /&gt;do &lt;BR /&gt;echo "Display Menu" &lt;BR /&gt;resp=* &lt;BR /&gt;read resp &lt;BR /&gt;case $resp in &lt;BR /&gt;[R,r])&lt;BR /&gt;run cmd....&lt;BR /&gt;exit_code=$?&lt;BR /&gt;;;&lt;BR /&gt;[C,c])&lt;BR /&gt;RETURN="yes"&lt;BR /&gt;;;&lt;BR /&gt;&lt;BR /&gt;[q,Q]) &lt;BR /&gt;echo "$program: $exit_code" &lt;BR /&gt;exit 0 &lt;BR /&gt;;; &lt;BR /&gt;&lt;BR /&gt;*) &lt;BR /&gt;echo Invalid Responce &lt;BR /&gt;sleep 1 &lt;BR /&gt;;; &lt;BR /&gt;esac &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;I have revised the above code, it continues if "C" or "c" is entered.</description>
      <pubDate>Thu, 19 Jun 2003 14:36:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002406#M718610</guid>
      <dc:creator>twang</dc:creator>
      <dc:date>2003-06-19T14:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002407#M718611</link>
      <description>Thanks Hai and all - I think I got it now !&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Jun 2003 14:56:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002407#M718611</guid>
      <dc:creator>Christopher Hildrum_1</dc:creator>
      <dc:date>2003-06-19T14:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Looping a ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002408#M718612</link>
      <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;Just an addition.&lt;BR /&gt;&lt;BR /&gt;"continue" is very useful only in loop controls. i.e. when you are using while, for etc... If the statement "continue" is not in a loop, it is equal to not writing the statement itself.&lt;BR /&gt;&lt;BR /&gt;Do not use "continue" frequently in one script as the performance comes down. I read it in some book that in big loops if you are using continue, the internal stack needs to be loaded many times and so the speed comes down. For small loops, you can use it.&lt;BR /&gt;&lt;BR /&gt;Thanks and Regards&lt;BR /&gt;VJ.</description>
      <pubDate>Fri, 20 Jun 2003 07:49:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/looping-a-ksh-script/m-p/3002408#M718612</guid>
      <dc:creator>vasundhara</dc:creator>
      <dc:date>2003-06-20T07:49:42Z</dc:date>
    </item>
  </channel>
</rss>

