<div dir="ltr">Annie,<div><br></div><div>The shell quoting is tricky, especially in combination with a shell variable. NCL needs to receive both double quotes and spaces within a single shell "word" as a single command argument.</div><div><br></div><div>The following uses two different quoting methods for different parts of the argument "word". There is more than one way to do this.</div><div><br></div><div>The square brackets in the NCL print statement are just for show.</div><div><br></div><div><div>mac56:~/temp/ncl 32> cat qtest.ncl</div><div>begin</div><div> print ("["+title+"]")</div><div>end</div><div>exit</div><div><br></div><div>mac56:~/temp/ncl 33> cat quote1.csh</div><div>#!/bin/csh</div><div>set title = "This is a title"</div><div>ncl qtest.ncl title=\""$title"\"</div><div><br></div><div>mac56:~/temp/ncl 34> ./quote1.csh </div><div> NCAR Command Language Version 6.3.0</div><div>(0)<span class="" style="white-space:pre">        </span>[This is a title]</div></div><div><br></div><div>--Dave</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 22, 2016 at 2:37 PM, Annie Seagram <span dir="ltr"><<a href="mailto:aseagram@sonomatech.com" target="_blank">aseagram@sonomatech.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">I have seen a number of discussions regarding passing strings as variables to ncl scripts from csh (e.g.
<a href="https://www.ncl.ucar.edu/Support/talk_archives/2010/2386.html)" target="_blank">here</a>) and I have read through the
<a href="https://www.ncl.ucar.edu/Applications/system.shtml#SHCLA" target="_blank">NCL systems interactions page</a>, but I can’t figure out how to pass a string that has a space in it.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">For example, on the command line one could specify:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">ncl year=2014 month=5 'title="This is a title"' myscript.ncl<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">However, in a csh script how does one pass the title as a variable? It seems to crash when there are spaces. e.g.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">This works:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">#!/bin/csh -f<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">set title = “Thisisatitle”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">ncl year=2014 month=5 title=</span>
<span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">\"{$title}\" myscript.ncl<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">This fails:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">#!/bin/csh -f<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">set title = “This is a title”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">ncl year=2014 month=5 title=</span>
<span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">\"{$title}\" myscript.ncl<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">The error:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">Missing }.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">Missing }.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">Is there a way to escape this behavior? I’d like to avoid setting environment variables.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">Thanks for your help.<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></p><span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Segoe UI","sans-serif"">-annie</span></p></font></span></div></div></blockquote></div></div></div>