[Thread Prev][Thread Next][Index]

Re: [ferret_users] whether any provision is available to use shell commands, with ferret



Hi Akshay,

> Yes ferret allows that. You need to use *spawn ls *.nc*.
> Then you can consider the repeat for the loop like this:
> *let ii=0;*
> *let model={spawn:"ls *.nc"};**
> **repeat/range=1:number_of_files (let ii=`ii+1`; let a=model[i=`ii`];use
> **`a`;\**
> **.......**! your commands
> **)*

As DIASSO shows, ferret has its own scripting language that includes
a loop capability.

Another approach is to use a shell script to produce a ferret script
and run ferret from within it:

# --- BEGIN shell script ---
scr=ferscript.jnl

for file in *.nc; do
  cat >> $scr <<END
    use $file
    let/units="meter"/title="my title" myvariable1 = xyz_new1
    let/units="cm"/title="my title" myvariable2 = xyz_new2
    list/file=${file}_modifile.nc/format=cdf/clobber xyz_new1, xyz_new2
END
done

ferret -script $scr
# --- END shell script ---

I haven't tested this shell script.  You sometimes have to fiddle
with quoting to take care of special characters.

Cheers,
Ryo


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement