Re: systemfunc question

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 01 2010 - 08:36:11 MDT

The problem is that you are imbedding double quotes within double quotes. NCL doesn't allow you to do this.

If you need a double quote to be part of your string, then you need to create a variable that contains the double quote, and construct the string.

For example (untested)

 dq = str_get_dq()
 cmd = "grep " + dq + "parameter(iproj=" + dq + " domain.param | sed " + dq + "s/parameter(iproj='\(\w\+\)'.*/\1/" + dq
 proj = systemfunc(proj)

--Mary

On May 31, 2010, at 4:32 PM, Mark Snyder wrote:

> Hi,
>
> I'm attempting to read a string from a text file using systemfunc:
>
> begin
>
> proj = systemfunc("grep "parameter(iproj=" domain.param | sed "s/parameter(iproj='\(\w\+\)'.*/\1/"")
> print(proj)
>
> end
>
> And it seems that NCL is balking at the ( between parameter and iproj (note the dashes are shorter in the email than what appears in the terminal, so the ^ points to the end of the line). I was looking at the documentation for a way to escape the ( but didn't find anything.
>
> Copyright (C) 1995-2009 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.1.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> fatal:syntax error: line 6 in file read_domain.param.ncl before or near parameter
> proj = systemfunc("grep "parameter
> ---------------------------------^
>
> fatal:Syntax Error in block, block not executed
> fatal:error at line 9 in file read_domain.param.ncl
>
> Thanks,
> Mark
>
>
> --
> Mark A. Snyder, PhD | Assistant Project Earth Scientist
> Climate Change and Impacts Laboratory
> Dept. of Earth and Planetary Sciences
> University of California, Santa Cruz
> (W) 831-459-3504 | msnyder@pmc.ucsc.edu
> http://es.ucsc.edu/~msnyder
> --
> <domain.param>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 1 08:36:16 2010

This archive was generated by hypermail 2.1.8 : Tue Jun 01 2010 - 09:12:20 MDT