LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   tcsh script: how to see if an env var is defined? (https://www.linuxquestions.org/questions/programming-9/tcsh-script-how-to-see-if-an-env-var-is-defined-190908/)

BrianK 06-07-2004 09:07 PM

tcsh script: how to see if an env var is defined?
 
If I do:
Code:

#!/bin/tcsh -f

if ( ! (-e $JOB1) ) then
    echo \$JOB1 must be defined
endif

I get "JOB1: Undefined variable."

How can I test if the variable is defined or not and take my own action?

BrianK 06-07-2004 10:12 PM

answered my own question, it should be:

Code:

if ( ! ($?JOB1) ) then
    echo
    echo "    *** ERROR! ***"
    echo
    echo ' '\$JOB1 must be defined
    exit
endif

:)


All times are GMT -5. The time now is 10:52 AM.