[Thread Prev][Thread Next][Index]

Re: [ferret_users] How to pass the value from a ferret script to a c shell file ?



Hi Chin,
                     If your objective involves taking a single variable from ferret to shell below method should work. 
#!/bin/csh -f
#embedded ferret script
ferret << STOP
let xx=10
let yy=150
let kf=xx+yy
list /clobber/file=kf.dat/nohead kf
exit
STOP
#starting c shell commands
set varInCshell = `head -1 kf.dat`
echo $varInCshell
endif

Sudheer

On Fri, Oct 28, 2011 at 6:50 AM, Hsu,Wen Chin <wenchin@xxxxxxx> wrote:
Hi,
I am not sure which email is correct one for ferret. If I send the question twice, sorry about it.
I usually embedded a ferret script in my c shell files when I need to use ferret.
However, I do not know how to save the value of a variable in ferret script and pass that value
to another variable in my c shell file. For example, I have a c shell file called aFile.csh and in it, it has something as

"#!bin/csh -f
.....
....
#embedded ferret script
ferret << STOP

use data.nc
let variableInFerret = x + y

exit
STOP
......
#starting c shell commands
set varInCshell = $variableInFerret

if( $varInCshell > 100 ) then
echo "it is 100"
endif
...
"
I calculated the value for variable, variableInFerret in ferret script and use it in my c shell file such as assigning it
to another variable and testing it.Now, I can only think of saving the value in a file by using LIST command in ferret and
then read value from it in c shell. However, it seems very inefficient. I wonder if there is any other way to achieve the same
goal.Thank you very much,




--
with best regards

Sudheer

**********************************************************************************
Sudheer Joseph                                                                 
Scientist                                                                                    
INDIAN NATIONAL CENTRE FOR OCEAN INFORMATION SERVICES (INCOIS)
MINISTRY OF EARTH SCIENCES, GOVERNMENT OF INDIA
"OCEAN VALLEY" PRAGATHI NAGAR (BO)
OPP.JNTU, NIZAMPET SO

Andhra Pradesh, India. PIN- 500 090.
TEl:+91-40-23044600(R),Tel:+91-9440832534(Mobile)
Tel:+91-40-23886047(O),Fax:+91-40-23892910(O)
E-mail: sudheer.joseph@xxxxxxxxxsjo@xxxxxxxxxxxxx.
Web- http://oppamthadathil.tripod.com
           --------------* ---------------
"The ultimate measure of a man is
not where he stands in moments of
comfort and convenience, but where
he stands at times of challenge and
controversy."
                        Martin Luther King, Jr.
"What we have done for ourselves alone dies with us.
What we have done for others and the world remains and is immortal."
- Albert Pines

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

Privacy Policy | Disclaimer | Accessibility Statement