Re: NCL as a scripting language: one step further

From: Rob Nicholas <rnicholas_at_nyahnyahspammersnyahnyah>
Date: Thu, 14 May 2009 13:30:13 -0700

Thanks for your response, Mary, and for adding my request to the (I
suspect already-too-long) to-do list.

As a follow-up, I discovered that the following also works:

   #!/bin/bash
   ncl <<EOF
   begin
      .
      .
      .
   end
   EOF

This is a smidgen more cumbersome than the "ideal" approach that I
suggested in my previous post, but it probably achieves the same
result in most cases while still allowing one to avoid writing and
then deleting a temporary file containing the NCL script.

~Rob

On Wed, May 13, 2009 at 9:20 PM, Mary Haley <haley_at_ucar.edu> wrote:
>
> Hi Rob,
>
> You bring up an interesting question. I'm afraid the answer is
> "no", there's no way to get the first (or any) line to be ignored,
> unless it has a ";" in front.
>
> And, technically, fatal errors are supposed to cause NCL to
> exit, but our error handling is not consistent in this manner.
> (Something we're planning to remedy.)
>
> I can see the value of your request, and I'll put it on the list.
>
> --Mary
>
>
>
> On Wed, 13 May 2009, Rob Nicholas wrote:
>
>> Hi all,
>>
>> I know that many folks use NCL within Csh or Bash script using
>> something like the following approach:
>>
>>  #!/bin/sh
>>  cat > temp_ncl_script.ncl << EOF
>>  begin
>>     .
>>     .
>>     .
>>  end
>>  EOF
>>  ncl temp_ncl_script.ncl
>>  rm temp_ncl_script.ncl
>>
>> However, it turns out that the following *simpler* approach will also
>> work...
>>
>>  #!/usr/local/bin/ncl
>>  begin
>>     .
>>     .
>>     .
>>  end
>>
>> ...but with one minor problem: NCL generates an error on the first
>> line of the script.  Does anyone know of a way to get NCL to ignore
>> the opening line of the above script when it is executed directly from
>> the shell?
>>
>> While I'm on the subject, I'd like to make a request to the
>> developers:  Although both # and ! have particular meanings within
>> NCL, would it be possible to have NCL ignore the first line of a
>> script if it begins with a "#!"?  If not added as a standard behavior,
>> could it be enabled with a command line option?
>>
>> Thanks,
>> Rob
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
Received on Thu May 14 2009 - 14:30:13 MDT

This archive was generated by hypermail 2.2.0 : Tue May 19 2009 - 09:17:29 MDT