[ncl-talk] Pass a string to ncl via csh that contains a space
Karl-Hermann Wieners
karl-hermann.wieners at mpimet.mpg.de
Fri Apr 1 02:12:09 MDT 2016
Hi Annie,
On 03/22/2016 09:37 PM, Annie Seagram wrote:
> However, in a csh script how does one pass the title as a variable? It
> seems to crash when there are spaces. e.g.
>
> This fails:
>
> #!/bin/csh -f
>
> set title = “This is a title”
>
> ncl year=2014 month=5 title= \"{$title}\" myscript.ncl
>
> The error:
>
> Missing }.
There are two answers to this:
(1) Use double quotes instead of curlies:
#!/bin/csh -f
set title = "This is a title"
ncl year=2014 month=5 title=\""$title"\" myscript.ncl
(2) If you need this often, you may want to try a wrapper script for
ncl, called nclsh, (see gzipped attachment) which - if put in PATH - may
be called like ncl, but passes any command line options as NCL args,
creating quotes internally:
#!/bin/csh -f
set title = "This is a title"
nclsh --year=2014 --month=5 --title="$title" myscript.ncl
More information may be found at
https://code.zmaw.de/projects/nclsh/news/
Best,
Karl
--
Karl-Hermann Wieners
Max-Planck-Institut für Meteorologie
Bundesstraße 53
20146 Hamburg
Germany
phone: +49 40 41173 161
email: karl-hermann.wieners at mpimet.mpg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nclsh.gz
Type: application/gzip
Size: 3580 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160401/af454af4/attachment.bin
More information about the ncl-talk
mailing list