[Thread Prev][Thread Next][Index]

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

The script option for starting Ferret is listed under "batch modes" in Ferret,

On 10/31/2011 1:44 PM, Hsu,Wen Chin wrote:
Thank you all for answering my question.
So far I used the Sudheer's suggestion but I am also trying Ryo and your idea.
Here are some confusions.

1) I searched on Ferret website but can not find description of usage of "-script" flag, can someone let me know where I can find more details about it ? I only know the "-batch" flag.
Are they the same thing ?

2)For Ryo, strangely I couldn't find your reply. I found your reply embedded in Ansley's reply. Would you please email your reply to me again ? Thank you very much. In addition, when you mentioned "command_to_process_ferrets_output", could you give me an example ? I assume the demonstration is
an example written inside a shell script right? Thanks,

On Mon, 31 Oct 2011 10:27:36 -0700, Ansley Manke wrote:
Hi -
I think that Sudheer's suggestion is the simplest.

In general to run Ferret under some other program, using -script is
preferable. Piping input into Ferret can run into problems if the
script is long.  Here are some old references from the Users List on
that topic.



On 10/27/2011 7:50 PM, Ryo Furue wrote:

| 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.

Does anybody know how to suppress messages from Ferret other than
using the -script flag?  Without the "-script" flag, we have
startup messages like

      FERRET v6.61
         . . .

and "yes?" prompts.

For now, I use the "-script" flag, which complicates my solution
shown below.

In principle, you can "print" the value using the SAY
command of Ferret and capture it from your shell script.
It's the standard way of communication between processes
within a shell script.

I'm attaching a small demonstration. I use the Bourne Shell
because I don't know the C Shell well enough.

The basic idea is

   ferret<<STOP  | command_to_process_ferrets_output
   let a = 3.14
   say `a`

where you read lines from Ferret in
command_to_process_ferrets_output .

But, if you do this, you end up seeing extra information printed
out by Ferret as I mentioned above.  So, in my demonstration,
I use the "-script" flag and a named pipe for the script.
Since it's a demonstration, I omitted error handling.

As an aside, a named pipe is necessary when your lines are long.
As far as I know, the maximum length of a line is a lot smaller
when reading the standard input than when reading a script file.


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

Privacy Policy | Disclaimer | Accessibility Statement