Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Posts
    26

    Thumbs down Unanswered: how to check environment variable in script

    hi

    i have to write script that includes checking environment variables are seted or not

    imagin $ENV is there how can i check wherther it is seted or not in script


    pls help me

  2. #2
    Join Date
    Aug 2004
    Location
    Rome, Italy
    Posts
    81
    Hi,
    you can test the length of the variablelike this
    if test ${#ENV} -eq 0
    then
    echo "Variable Empty"
    fi

    or you can do like this
    echo ${ENV:-ERROR"}
    which will display the word "ERROR" if the variable is empty, otherwise will display the value of ENV


    bye,
    ducasio

  3. #3
    Join Date
    Aug 2004
    Location
    Rome, Italy
    Posts
    81
    in my solution I missed a double quote(") in writing, so it must be:

    echo ${ENV:-"ERROR"}

    Bye,
    ducasio

Posting Permissions

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