On Jun 25, 9:40 am, michael <[EMAIL PROTECTED]> wrote:
> Hi, I have acshscript in which I'd like to do set up a list of vars
> and then to chk each of these are set, something like the below.
> However, I can't find the magic incantation that allows to to check
> ${$Vars} eg if $InMetFiles is set on the first loop - suggestions
> welcome!
>
> #!/bin/csh
> foreach Vars (InMetFiles InTerFile OutDir)
>   echo Checking $Vars\.\.\.
>   if ( ${?Vars} == 0) then
>     echo $Vars not set \- aborting
>     exit 1
>   endif
> end
>
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

its ugly but I think this works

#!/bin/csh

foreach Vars (Var1 Var2 Var3)
    echo checking $Vars\.\.\.
    setenv temp '${'$Vars'}'
    setenv temp2 `eval echo 'X'$temp >&/dev/null`
    if ( "$status" != "0" ) then
        echo $Vars not set \- aborting
        exit 1
    endif
end


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to