puzzled with using getenv for getting shell environment variable

From: Erik N <nobleeu_at_nyahnyahspammersnyahnyah>
Date: Tue Nov 01 2011 - 10:45:33 MDT

I'm having difficulty with passing a shell environment variable to the
ncl script with the getenv command.
The environment variable is "fil."
The shell script works fine.
But when I look at the ncl output using the print statement, the
string is missing. It is supposed to say "ncep2_grid_Experiment_.... "
Is this expected?


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; shell script
[nobleeu@Erik-Nobles-iMac] ncep2_grid $ cat loop_ncl_script.sh

#!/usr/bin/env bash
# loop through set of files with a ncl script
export WORKDIR=$HOME/myWorkDir/POST_PROCESSING/20km_CAM_6_hour/winds/ncep2_grid
export SCRIPTDIR=.$HOME/myWorkDir/myScripts/ncl/

# List Files
echo $PWD
export FILI="ls ncep2_grid_Experiment_*"
echo $FILI
# Loop through list of files
for fil in $FILI
                if [ ! -e "$fil" ] # Check if file exists.
        echo "$fil does not exist."; echo
        continue # On to next.
        # echo "Extract Variable from $fil . "
                # Execute script <- make sure that ncl script reads env. variable $fil
                time ncl test.ncl
echo "Finished."
exit 0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;NCL CODE

file_in = getenv("fil")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;TERMINAL OUTPUT when executing shell script

[nobleeu@Erik-Nobles-iMac] ncep2_grid $ ./loop_ncl_script.sh
ls ncep2_grid_Experiment_01_UV.nc ncep2_grid_Experiment_02_UV.nc
ncep2_grid_Experiment_03_UV.nc ncep2_grid_Experiment_04_UV.nc
ncep2_grid_Experiment_05_UV.nc ncep2_grid_Experiment_06_UV.nc
ncep2_grid_Experiment_07_UV.nc ncep2_grid_Experiment_08_UV.nc
ncep2_grid_Experiment_09_UV.nc ncep2_grid_Experiment_10_UV.nc
ncep2_grid_Experiment_11_UV.nc ncep2_grid_Experiment_12_UV.nc
ncep2_grid_Experiment_13_UV.nc ncep2_grid_Experiment_14_UV.nc
ncep2_grid_Experiment_15_UV.nc ncep2_grid_Experiment_16_UV.nc
ncep2_grid_Experiment_17_UV.nc ncep2_grid_Experiment_18_UV.nc
ncep2_grid_Experiment_19_UV.nc ncep2_grid_Experiment_20_UV.nc
ncep2_grid_Experiment_21_UV.nc ncep2_grid_Experiment_22_UV.nc
ncep2_grid_Experiment_23_UV.nc ncep2_grid_Experiment_24_UV.nc
ncep2_grid_Experiment_25_UV.nc ncep2_grid_Experiment_26_UV.nc
ncep2_grid_Experiment_27_UV.nc ncep2_grid_Experiment_28_UV.nc
ncep2_grid_Experiment_29_UV.nc ncep2_grid_Experiment_30_UV.nc
ncep2_grid_Experiment_31_UV.nc ncep2_grid_Experiment_32_UV.nc
ls does not exist.

Working on ncep2_grid_Experiment_01_UV.nc
 Copyright (C) 1995-2011 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.0.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.

Variable: file_in
Type: string
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Number Of Attributes: 1
  _FillValue : missing
(0) missing

real 0m0.173s
user 0m0.011s
sys 0m0.008s

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Tue Nov 1 10:45:44 2011

This archive was generated by hypermail 2.1.8 : Tue Nov 01 2011 - 13:43:04 MDT