<?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: scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938799#M797675</link>
    <description>Wonder why all the scripting experts that correctly explained the odd [ x$1 != "x" ] shell idiom to you haven't mentioned the double square brackets test "operator" yet.&lt;BR /&gt;If you are using any contempory Bourne shell compatible like ksh, bash, or HP-UX sh,&lt;BR /&gt;the the odd idiom isn't needed and obsolete&lt;BR /&gt;because the [[ ]] test command prevents word splitting and pathname globbing but does all the variable, parameter, command and arithmetic expansions.&lt;BR /&gt;This lets you write more tangibly&lt;BR /&gt;  &lt;BR /&gt;while [[ $1 != "" ]]; do&lt;BR /&gt;  &lt;BR /&gt;or better yet&lt;BR /&gt;  &lt;BR /&gt;while [[ -n $1 ]]; do&lt;BR /&gt;  &lt;BR /&gt;or even as arithmetic expression,&lt;BR /&gt;but probably more obfuscated&lt;BR /&gt;  &lt;BR /&gt;while (( ${#1} )); do&lt;BR /&gt;</description>
    <pubDate>Tue, 08 Nov 2005 18:28:02 GMT</pubDate>
    <dc:creator>Ralph Grothe</dc:creator>
    <dc:date>2005-11-08T18:28:02Z</dc:date>
    <item>
      <title>scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938784#M797660</link>
      <description>In a script what does the following while loop translate to:&lt;BR /&gt;&lt;BR /&gt;while [ x$1 != "x" ]&lt;BR /&gt;&lt;BR /&gt;I have not done scripting before and do not understand the arguments inside the while loop (brackets) as above.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Nov 2005 07:10:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938784#M797660</guid>
      <dc:creator>Ravinder Singh Gill</dc:creator>
      <dc:date>2005-11-07T07:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938785#M797661</link>
      <description>It means while x$1 not eqal to x&lt;BR /&gt;$1=varibale defined.</description>
      <pubDate>Mon, 07 Nov 2005 07:15:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938785#M797661</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-11-07T07:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938786#M797662</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;while [ x$1 != "x" ]&lt;BR /&gt;&lt;BR /&gt;$1 means command line parameter for your script. Suppose you script name is "run.sh"&lt;BR /&gt;&lt;BR /&gt;# run.sh Gill&lt;BR /&gt;&lt;BR /&gt;here $1=Gill&lt;BR /&gt;    x$1=xGill&lt;BR /&gt;&lt;BR /&gt;If # run.sh &lt;BR /&gt;Here $1= null&lt;BR /&gt;    x$1=x&lt;BR /&gt;&lt;BR /&gt;This while loop says&lt;BR /&gt;x$1 is not equal to x.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Rajesh</description>
      <pubDate>Mon, 07 Nov 2005 07:23:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938786#M797662</guid>
      <dc:creator>Rajesh SB</dc:creator>
      <dc:date>2005-11-07T07:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938787#M797663</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;it is a kind of standard trick for detecting if a variable has been set.&lt;BR /&gt;In this case it checks if the script in which it is used has been activated with a parameter(=$1) or not: if $1 is non-exisiting, then x$1 is equal to x&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Mon, 07 Nov 2005 07:55:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938787#M797663</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2005-11-07T07:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938788#M797664</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;The expression will evaluate to true if "$1" isn't empty, otherwise it will evaluate to false.&lt;BR /&gt;&lt;BR /&gt;You can easily see this by doing:&lt;BR /&gt;&lt;BR /&gt;cat /tmp/debug&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;if [ x$1 != "x" ]; then&lt;BR /&gt;echo ok&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# sh -x /tmp/debug     #...no  arguments&lt;BR /&gt;# sh -x /tmp/debug arg #...any argument&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 07 Nov 2005 07:58:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938788#M797664</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-07T07:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938789#M797665</link>
      <description>Thanks guys</description>
      <pubDate>Mon, 07 Nov 2005 08:02:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938789#M797665</guid>
      <dc:creator>Ravinder Singh Gill</dc:creator>
      <dc:date>2005-11-07T08:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938790#M797666</link>
      <description>But what is x?&lt;BR /&gt;&lt;BR /&gt;The script is as follows:&lt;BR /&gt;&lt;BR /&gt;       echo "Please enter the User's Surname and first TWO Christian Names only, "&lt;BR /&gt;        echo "separated by spaces. Please use only lower case. CTRL-C to exit."&lt;BR /&gt;        echo&lt;BR /&gt;        echo "For example \"jones derick richard\" for Derick Richard Jones."&lt;BR /&gt;        echo&lt;BR /&gt;        echo "  User's name (lower case only): \c"&lt;BR /&gt;        read NAME&lt;BR /&gt;        unset CHR1 CHR2 SURNAME EXIST USERCHECK&lt;BR /&gt;        COUNT=0&lt;BR /&gt;        set $NAME&lt;BR /&gt;        while [ x$1 != "x" ]&lt;BR /&gt;        do&lt;BR /&gt;                COUNT=`expr $COUNT + 1`&lt;BR /&gt;                case $COUNT in&lt;BR /&gt;                      1) SURNAME=$1 ;;&lt;BR /&gt;                        2) CHR1=$1 ;;&lt;BR /&gt;                        3) CHR2=$1 ;;&lt;BR /&gt;                esac&lt;BR /&gt;                shift 1&lt;BR /&gt;        done&lt;BR /&gt;        INIT1=`echo $CHR1 | cut -c1`&lt;BR /&gt;        INIT2=`echo $CHR2 | cut -c1`&lt;BR /&gt;        if [ x$INIT2 = "x" ]&lt;BR /&gt;        then&lt;BR /&gt;                INIT2=a&lt;BR /&gt;        fi&lt;BR /&gt;        SNAME=`echo $SURNAME | cut -c1-5`&lt;BR /&gt;&lt;BR /&gt;        while [ ${#SNAME} -lt 5 ]&lt;BR /&gt;        do&lt;BR /&gt;          SNAME=$SNAME"a"&lt;BR /&gt;        done&lt;BR /&gt;&lt;BR /&gt;        UNAME=`echo $SNAME$INIT1$INIT2`&lt;BR /&gt;&lt;BR /&gt;        USERCHECK=`echo "$UNAME:"`&lt;BR /&gt;        EXIST=`grep $USERCHECK /etc/passwd | awk -F: {'print $1'}`&lt;BR /&gt;&lt;BR /&gt;        if [ x$EXIST != "x" ]&lt;BR /&gt;        then&lt;BR /&gt;                COUNT=1&lt;BR /&gt;                for i in $EXIST&lt;BR /&gt;                do&lt;BR /&gt;                      COUNT=`expr $COUNT + 1`&lt;BR /&gt;                done&lt;BR /&gt;                UNAME=`echo $UNAME$COUNT`&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;        HOMEDIR="/home/gvts"&lt;BR /&gt;        if [ $INIT2 = a ]&lt;BR /&gt;        then&lt;BR /&gt;                COMMENTS="STAFF $CHR1 $SURNAME"&lt;BR /&gt;        else&lt;BR /&gt;                COMMENTS="STAFF $CHR1 $CHR2 $SURNAME"&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;        clear&lt;BR /&gt;        echo&lt;BR /&gt;        echo "                          GVTS User creation utility"&lt;BR /&gt;        echo "                          ~~~~~~~~~~~~~~~~~~~~~~~~~~"&lt;BR /&gt;        echo&lt;BR /&gt;        echo "The user account will be created as follows:"&lt;BR /&gt;        echo&lt;BR /&gt;        echo "  User ID: $UNAME"&lt;BR /&gt;#       echo "  User ID2: $UNAME"t""&lt;BR /&gt;        echo "  Home directory: $HOMEDIR"&lt;BR /&gt;      echo "  Comments: $COMMENTS"&lt;BR /&gt;        sleep 3&lt;BR /&gt;&lt;BR /&gt;        echo "useradd -g gvts -s /bin/false -d $HOMEDIR -c \"$COMMENTS\" $UNAME" &amp;gt; u&lt;BR /&gt;#       echo "useradd -g gvts -s /bin/false -d $HOMEDIR -c \"$COMMENTS\" $UNAME"t"" &amp;gt;&amp;gt; u&lt;BR /&gt;        echo "echo "Enter password for $UNAME"" &amp;gt;&amp;gt; u&lt;BR /&gt;        echo "passwd  $UNAME" &amp;gt;&amp;gt; u&lt;BR /&gt;#       echo "echo "Enter password for $UNAME"t""" &amp;gt;&amp;gt; u&lt;BR /&gt;#       echo "passwd  $UNAME"t"" &amp;gt;&amp;gt; u&lt;BR /&gt;        sh u&lt;BR /&gt;        rm u&lt;BR /&gt;done</description>
      <pubDate>Mon, 07 Nov 2005 09:24:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938790#M797666</guid>
      <dc:creator>Ravinder Singh Gill</dc:creator>
      <dc:date>2005-11-07T09:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938791#M797667</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;x is simply a random letter in this case.&lt;BR /&gt;It is not important which letter is used, in the script however, x is used: &lt;BR /&gt;&lt;BR /&gt; while [ x$1 != "x" ]&lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;BR /&gt;if [ x$INIT2 = "x" ]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;you could as well have used:&lt;BR /&gt;&lt;BR /&gt;while [ y$1 != "y" ]&lt;BR /&gt;&lt;BR /&gt;and &lt;BR /&gt;&lt;BR /&gt;if [ z$INIT2 = "z" ]&lt;BR /&gt;&lt;BR /&gt;the idea is simply to test if the accompanying variable, $1 and $INIT2, respectively, have been set, i.e. do they have a value or are they equal to nothing.&lt;BR /&gt;If equal to nothing, the letter chosen is equal to the letter chosen!&lt;BR /&gt;&lt;BR /&gt;In you script the idea is to repeat the question until the user supplies input, which then is considered $1 by the script.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Mon, 07 Nov 2005 09:46:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938791#M797667</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2005-11-07T09:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938792#M797668</link>
      <description>In your script, x is nothing more than a error prevention device.&lt;BR /&gt;&lt;BR /&gt;The statement while[x$1 != "x" ] breaks down like this&lt;BR /&gt;&lt;BR /&gt;$1 is the command line parameter.  As stated above if your script is run.sh the command line parameters would be Smith and William and the first ($1) would be Smith&lt;BR /&gt;&lt;BR /&gt;#run.sh Smith William&lt;BR /&gt;&lt;BR /&gt;if you just execute the script with no parameters $1 is a null and the test program ([) will return an error like value expected.  However, if instead of testing for just $1, you append something to the front of $1, for instance x, then you get x$1 which translates to xSmith in the example above but only to x if you provide no parameters.  Now your have something to test with that will not return the value expected, sense it will always have at least the value of x.&lt;BR /&gt;&lt;BR /&gt;thatâ  s why the test is for "x" and not "" if no parameter is provided.&lt;BR /&gt;&lt;BR /&gt;In the case of your script, what its doing is, if there is no parameter (in this case names) sent then it asks for them in the script, if there is a parameter, (the name) it has the name and doesnâ  t need to prompt for it inside the script.&lt;BR /&gt;&lt;BR /&gt;Hope that helps&lt;BR /&gt;&lt;BR /&gt;H&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Nov 2005 10:24:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938792#M797668</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2005-11-07T10:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938793#M797669</link>
      <description>In your script "x" is a constant.  It is simply the letter "x".  It can be any other value you want (I would say away from metacharacters).</description>
      <pubDate>Mon, 07 Nov 2005 10:56:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938793#M797669</guid>
      <dc:creator>Gary L. Paveza, Jr.</dc:creator>
      <dc:date>2005-11-07T10:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938794#M797670</link>
      <description>Can you guys offer some explanation of the rest of the script. I am aware of what it does on a general level, but do not understand some of the commands/technical bits etc</description>
      <pubDate>Mon, 07 Nov 2005 11:12:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938794#M797670</guid>
      <dc:creator>Ravinder Singh Gill</dc:creator>
      <dc:date>2005-11-07T11:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938795#M797671</link>
      <description>&lt;BR /&gt;echo&lt;BR /&gt;echo " User's name (lower case only): \c"&lt;BR /&gt;read NAME&lt;BR /&gt;unset CHR1 CHR2 SURNAME EXIST USERCHECK&lt;BR /&gt;COUNT=0&lt;BR /&gt;set $NAME&lt;BR /&gt;&lt;BR /&gt;set name as first parameter (aka $1)&lt;BR /&gt;&lt;BR /&gt;while [ x$1 != "x" ]&lt;BR /&gt;do&lt;BR /&gt;COUNT=`expr $COUNT + 1`&lt;BR /&gt;case $COUNT in&lt;BR /&gt;1) SURNAME=$1 ;;&lt;BR /&gt;2) CHR1=$1 ;;&lt;BR /&gt;3) CHR2=$1 ;;&lt;BR /&gt;esac&lt;BR /&gt;shift 1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;assign NAME to SURNAME, then CHR1 then CHR2&lt;BR /&gt;&lt;BR /&gt;INIT1=`echo $CHR1 | cut -c1`&lt;BR /&gt;INIT2=`echo $CHR2 | cut -c1`&lt;BR /&gt;&lt;BR /&gt;make INIT1 initial of CHR1, INIT2 liekwise&lt;BR /&gt;&lt;BR /&gt;if [ x$INIT2 = "x" ]&lt;BR /&gt;then&lt;BR /&gt;INIT2=a&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if no INIT2, then assing aritrary a to INIT2&lt;BR /&gt;&lt;BR /&gt;SNAME=`echo $SURNAME | cut -c1-5`&lt;BR /&gt;&lt;BR /&gt;SNAME is first 5 letter of surname ...&lt;BR /&gt;&lt;BR /&gt;while [ ${#SNAME} -lt 5 ]&lt;BR /&gt;do&lt;BR /&gt;SNAME=$SNAME"a"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;...padded with "a"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;UNAME=`echo $SNAME$INIT1$INIT2`&lt;BR /&gt;&lt;BR /&gt;now Joe Doe gave UNAME=doeaaja&lt;BR /&gt;and Joe Mike Smithson gave smithjm&lt;BR /&gt;wow this gave a nice 7 letter login name !!!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;USERCHECK=`echo "$UNAME:"`&lt;BR /&gt;EXIST=`grep $USERCHECK /etc/passwd | awk -F: {'print $1'}`&lt;BR /&gt;&lt;BR /&gt;what about if name is alread on :etc/passwd ?&lt;BR /&gt;&lt;BR /&gt;if [ x$EXIST != "x" ]&lt;BR /&gt;then&lt;BR /&gt;COUNT=1&lt;BR /&gt;for i in $EXIST&lt;BR /&gt;do&lt;BR /&gt;COUNT=`expr $COUNT + 1`&lt;BR /&gt;done&lt;BR /&gt;UNAME=`echo $UNAME$COUNT`&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;count number of occurence (and prolly a syntax error here, one should write&lt;BR /&gt;if [ "x$EXIST" != "x" ]&lt;BR /&gt;instead of&lt;BR /&gt;if [ x$EXIST != "x" ]&lt;BR /&gt; besides, if there is more than 9 matches, resulting name might be 9 letter long, a problem on sone unixes ...)&lt;BR /&gt;&lt;BR /&gt;HOMEDIR="/home/gvts"&lt;BR /&gt;if [ $INIT2 = a ]&lt;BR /&gt;then&lt;BR /&gt;COMMENTS="STAFF $CHR1 $SURNAME"&lt;BR /&gt;else&lt;BR /&gt;COMMENTS="STAFF $CHR1 $CHR2 $SURNAME"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;prepare Gcos variable in /etc/passwd (5th filed) with real name.&lt;BR /&gt;&lt;BR /&gt;clear&lt;BR /&gt;echo&lt;BR /&gt;echo " GVTS User creation utility"&lt;BR /&gt;echo " ~~~~~~~~~~~~~~~~~~~~~~~~~~"&lt;BR /&gt;echo&lt;BR /&gt;echo "The user account will be created as follows:"&lt;BR /&gt;echo&lt;BR /&gt;echo " User ID: $UNAME"&lt;BR /&gt;# echo " User ID2: $UNAME"t""&lt;BR /&gt;echo " Home directory: $HOMEDIR"&lt;BR /&gt;echo " Comments: $COMMENTS"&lt;BR /&gt;sleep 3&lt;BR /&gt;&lt;BR /&gt;tell us about the creation of unix account (by the way where is HOMEDIR defined ?)&lt;BR /&gt;&lt;BR /&gt;echo "useradd -g gvts -s /bin/false -d $HOMEDIR -c \"$COMMENTS\" $UNAME" &amp;gt; u&lt;BR /&gt;# echo "useradd -g gvts -s /bin/false -d $HOMEDIR -c \"$COMMENTS\" $UNAME"t"" &amp;gt;&amp;gt; u&lt;BR /&gt;echo "echo "Enter password for $UNAME"" &amp;gt;&amp;gt; u&lt;BR /&gt;echo "passwd $UNAME" &amp;gt;&amp;gt; u&lt;BR /&gt;# echo "echo "Enter password for $UNAME"t""" &amp;gt;&amp;gt; u&lt;BR /&gt;# echo "passwd $UNAME"t"" &amp;gt;&amp;gt; u&lt;BR /&gt;sh u&lt;BR /&gt;rm u&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;where that's done comming from ? did you copy paste it all ?&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;are you having trouble with this script ?&lt;BR /&gt;does it run well ?&lt;BR /&gt;&lt;BR /&gt;Jean-Yves Picard&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Nov 2005 12:38:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938795#M797671</guid>
      <dc:creator>Jean-Yves Picard</dc:creator>
      <dc:date>2005-11-07T12:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938796#M797672</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;To add a little detail to the part where the user's input is read in:&lt;BR /&gt;&lt;BR /&gt;After presenting the instructions about how the user is supposed to enter his input:&lt;BR /&gt;&lt;BR /&gt;read NAME&lt;BR /&gt;...assigns all input made by the user into a single variable: if the user wrote:&lt;BR /&gt;skov ib bo&lt;BR /&gt;these three names will then all be kept in NAME&lt;BR /&gt;&lt;BR /&gt;set $NAME&lt;BR /&gt;...has the effect that the content of NAME is broken up into space separated items, i.e. positional parameters,  that can be addressed individually; now $1 contains the word skov, $2 contains the word ib, and $3 the word bo.&lt;BR /&gt;This is important to understand as the script seems to lose interes in the NAME variable!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The script now chews its way through these positional parameters:&lt;BR /&gt;&lt;BR /&gt;while [ x$1 != "x" ]&lt;BR /&gt;...until positional parameter no. 1 is "empty" do this;&lt;BR /&gt;&lt;BR /&gt;COUNT=`expr $COUNT + 1`&lt;BR /&gt;...add one to COUNT (first time COUNT is "1")&lt;BR /&gt;&lt;BR /&gt;case $COUNT in&lt;BR /&gt;...if COUNT is 1, 2, or 3, do the requested action for the value in question:&lt;BR /&gt;&lt;BR /&gt;1) SURNAME=$1 ;;&lt;BR /&gt;...COUNT is 1, assign the current $1 value, skov, to the variable SURNAME&lt;BR /&gt;...the script can select only a single option of the case-structure; as "1" was used the script then jumps to the end of the case-structure:&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;...at this moment there are still three positional parameters:&lt;BR /&gt;skov ib bo&lt;BR /&gt;&lt;BR /&gt;...but this is now changed by&lt;BR /&gt;shift 1&lt;BR /&gt;...which removes the previous $1 value, skov, leaving only&lt;BR /&gt;ib bo&lt;BR /&gt;...Notice that $1 is now ib&lt;BR /&gt;&lt;BR /&gt;...Then the loop is evaluated again:&lt;BR /&gt;while [ x$1 != "x" ]&lt;BR /&gt;...$1 is not empty, as it now contains&lt;BR /&gt;ib&lt;BR /&gt;&lt;BR /&gt;...COUNT is incremented by one&lt;BR /&gt;COUNT=`expr $COUNT + 1`&lt;BR /&gt;...And is now 2&lt;BR /&gt;&lt;BR /&gt;...Therefore the&lt;BR /&gt;case $COUNT in&lt;BR /&gt;...now enters&lt;BR /&gt;2) CHR1=$1 ;;&lt;BR /&gt;...Which assigns ib to CHAR1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Shift 1&lt;BR /&gt;...Changes $1 to&lt;BR /&gt; bo&lt;BR /&gt;&lt;BR /&gt;...and the third time we enter the loop bo is assigned to CHR2&lt;BR /&gt;&lt;BR /&gt;...after the third &lt;BR /&gt;shift 1&lt;BR /&gt;there is no longer any $1 and the evaluation&lt;BR /&gt;while [ x$1 != "x" ]&lt;BR /&gt;...is now true, e.g.&lt;BR /&gt;x is equal to x and the script jumps to the first line after done..&lt;BR /&gt;&lt;BR /&gt;A long explanation for a small part, but the way NAME is handled is a little tricky.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Nov 2005 14:28:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938796#M797672</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2005-11-07T14:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938797#M797673</link>
      <description>And just to add some expertise to your shell scripting, the tecnique:&lt;BR /&gt;&lt;BR /&gt;[ x$1 != "x" ]&lt;BR /&gt; &lt;BR /&gt;is now replaced with the more readable technique:&lt;BR /&gt; &lt;BR /&gt;[ "$1" != "" ]&lt;BR /&gt; &lt;BR /&gt;By placing the parameter ($1 in this case) within double quotes, the test for a missing or null value makes much more sense. If $1 is null or a zero-length string the test (the square brackets) will be correctly evaluated.</description>
      <pubDate>Mon, 07 Nov 2005 21:58:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938797#M797673</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-11-07T21:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938798#M797674</link>
      <description>Ravinder,&lt;BR /&gt;&lt;BR /&gt;This construct is quite old.  See Bill's answer for the current correct syntax.  &lt;BR /&gt;&lt;BR /&gt;Since this is an interactive script, it really needs to do a lot of error-checking.  Typically, when I write an interactive script, I'll test all the expected parameters with something like this:&lt;BR /&gt;&lt;BR /&gt;if [ -z $1 ] &lt;BR /&gt;then&lt;BR /&gt;  echo "Missing parameter."&lt;BR /&gt;  exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;The -z means if the value of the string $1 is null, evaluate to true.  The test(1m) man page will give you a much more detailed description.&lt;BR /&gt;&lt;BR /&gt;-or-&lt;BR /&gt;&lt;BR /&gt;if [ $# -ne 3 ]&lt;BR /&gt;then&lt;BR /&gt;  echo "Missing parameters."&lt;BR /&gt;  exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;The $# is the number (#) of parameters from the command line.  This code just says that if the number of parameters is not equal to 3 , then stop.&lt;BR /&gt;&lt;BR /&gt;You should always let the user know when something is wrong and stops the script.  This can be extremely important if the scripts does anything 'dangerous', like removing files.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Mark</description>
      <pubDate>Tue, 08 Nov 2005 11:36:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938798#M797674</guid>
      <dc:creator>Mark Ellzey</dc:creator>
      <dc:date>2005-11-08T11:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938799#M797675</link>
      <description>Wonder why all the scripting experts that correctly explained the odd [ x$1 != "x" ] shell idiom to you haven't mentioned the double square brackets test "operator" yet.&lt;BR /&gt;If you are using any contempory Bourne shell compatible like ksh, bash, or HP-UX sh,&lt;BR /&gt;the the odd idiom isn't needed and obsolete&lt;BR /&gt;because the [[ ]] test command prevents word splitting and pathname globbing but does all the variable, parameter, command and arithmetic expansions.&lt;BR /&gt;This lets you write more tangibly&lt;BR /&gt;  &lt;BR /&gt;while [[ $1 != "" ]]; do&lt;BR /&gt;  &lt;BR /&gt;or better yet&lt;BR /&gt;  &lt;BR /&gt;while [[ -n $1 ]]; do&lt;BR /&gt;  &lt;BR /&gt;or even as arithmetic expression,&lt;BR /&gt;but probably more obfuscated&lt;BR /&gt;  &lt;BR /&gt;while (( ${#1} )); do&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Nov 2005 18:28:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938799#M797675</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-11-08T18:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938800#M797676</link>
      <description>cheers for your help guys</description>
      <pubDate>Fri, 11 Nov 2005 05:27:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/4938800#M797676</guid>
      <dc:creator>Ravinder Singh Gill</dc:creator>
      <dc:date>2005-11-11T05:27:40Z</dc:date>
    </item>
  </channel>
</rss>

