<div dir="ltr"><div>FYI only: <br>The reverse of the original question. From an NCL script, pass a string to NCL's system procedure ...<br><br></div>An NCL script 'acting' like a shell script to invoke another NCL script :-)<br><div><div><br>===<br><br>The next release of NCL: 6.4.0 has an embarassingly simple utility function that I have used used that in someways simplifies text issues<br><br><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cla_sq.shtml">http://www.ncl.ucar.edu/Document/Functions/Built-in/cla_sq.shtml</a><br><br>undef("cla_sq")<br>function cla_sq(sleft[1]:string, sright[1]:string)<br>; Simple utility used for creating Command Line Assignments (CLAs) within a script<br>; <br>; Return a string with a single quote (sq) at the<br>; beginning and end which enclose *nix sensitive characters.<br>;<br>; [1] s = cla_sq("PATH","./<a href="http://FIM.G5test.nc">FIM.G5test.nc</a>") => 'PATH="./<a href="http://FIM.G5test.nc">FIM.G5test.nc</a>"'<br>;<br>; [2]<br>; asgn1 = cla_sq( "f", "<a href="http://test.nc">test.nc</a>") ; asgn1= 'f="<a href="http://test.nc">test.nc</a>"'<br>; asgn2 = cla_sq( "p", "(/850,500,200/)") ; asgn2= 'p=(/850,500,200/)'<br>; asgn3 = cla_sq("var", "(/"T","Q"/)" ; asgn3= 'var=(/"T","Q"/)'<br>; cmd = "ncl year=2015 "+asgn1+" "+asgn2+" "+asgn3+" foo.ncl"<br>; system(cmd)<br>;---<br>local sq<br>begin<br> sq = str_get_sq() ; single quote character<br> return(sq+ sleft +"="+sright +sq)<br>end<br><br></div><div>Maybe it will be useful.<br><br></div><div>D<br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 1, 2016 at 2:12 AM, Karl-Hermann Wieners <span dir="ltr"><<a href="mailto:karl-hermann.wieners@mpimet.mpg.de" target="_blank">karl-hermann.wieners@mpimet.mpg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Annie,<br>
<span class=""><br>
On 03/22/2016 09:37 PM, Annie Seagram wrote:<br>
> However, in a csh script how does one pass the title as a variable? It<br>
> seems to crash when there are spaces. e.g.<br>
><br>
</span><span class="">> This fails:<br>
><br>
> #!/bin/csh -f<br>
><br>
> set title = “This is a title”<br>
><br>
> ncl year=2014 month=5 title= \"{$title}\" myscript.ncl<br>
><br>
> The error:<br>
><br>
> Missing }.<br>
<br>
</span>There are two answers to this:<br>
<br>
(1) Use double quotes instead of curlies:<br>
<span class=""><br>
#!/bin/csh -f<br>
set title = "This is a title"<br>
ncl year=2014 month=5 title=\""$title"\" myscript.ncl<br>
<br>
</span>(2) If you need this often, you may want to try a wrapper script for<br>
ncl, called nclsh, (see gzipped attachment) which - if put in PATH - may<br>
be called like ncl, but passes any command line options as NCL args,<br>
creating quotes internally:<br>
<span class=""><br>
#!/bin/csh -f<br>
<br>
set title = "This is a title"<br>
</span>nclsh --year=2014 --month=5 --title="$title" myscript.ncl<br>
<br>
More information may be found at<br>
<a href="https://code.zmaw.de/projects/nclsh/news/" rel="noreferrer" target="_blank">https://code.zmaw.de/projects/nclsh/news/</a><br>
<br>
Best,<br>
Karl<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Karl-Hermann Wieners<br>
Max-Planck-Institut für Meteorologie<br>
Bundesstraße 53<br>
20146 Hamburg<br>
Germany<br>
phone: <a href="tel:%2B49%2040%2041173%20161" value="+494041173161">+49 40 41173 161</a><br>
email: <a href="mailto:karl-hermann.wieners@mpimet.mpg.de">karl-hermann.wieners@mpimet.mpg.de</a><br>
</font></span><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>