Results 1 to 2 of 2

Thread: String function

  1. #1
    Join Date
    May 2002
    Location
    Timbaktu
    Posts
    185

    Unanswered: String function

    My Situation:
    -Sservername
    user at the command prompt would be entering -S servername and I would like to capture servername value using the string fuction.
    What should I do??

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    I'm not sure to understand what you want to do...

    Something like this ?

    user: the_script ... -S servername ...

    Code:
    while [ $# -gt 0 ]
    do
       if [ "$1" = "-S" ]
       then
          if [ $# -le 1 ]
          then
             echo "Syntax error: missing servername"
             exit 1
          else
             servername=$2
             break
          fi
       fi
       shift
    done
    if [ -z "$servername" ]
    then
       echo "-S option not specified
    else
       echo "Servername: $servername"
    fi
    Jean-Pierre.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •