<div dir="ltr">Thank you Brian for your suggestion.<div><br></div><div>But the problem still persists even when I try</div><div>-------</div><div>cat myfile| while read mname <br>do<br>ncl myfile.ncl<br>done<br></div><div>-------</div><div><br></div><div>I am clueless what can go wrong here.</div><div><br></div><div>Regards,</div><div>Bidyut</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 23, 2021 at 5:15 AM Brian Thomas <<a href="mailto:brian.thomas@washburn.edu">brian.thomas@washburn.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Not certain, but I think your problem is the quotes around your variable name here:</span></div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">echo "$mname"</span></div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline"><br>
</span></div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Shouldn't have " " to make it echo out the contents of $mname</span></div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline"><br>
</span></div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Date: Thu, 22 Apr 2021 14:26:03 +0900</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">From: Bidyut Bikash Goswami <</span><a href="mailto:bidyut@yonsei.ac.kr" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">bidyut@yonsei.ac.kr</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">></span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">To:<span> </span></span><a href="mailto:ncl-talk@mailman.ucar.edu" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">ncl-talk@mailman.ucar.edu</a><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Subject: [ncl-talk] Running NCL script from shell script</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Message-ID:</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline"><</span><a href="mailto:CAOxJJSdjyHjprWvM-0C8Y20dp1dtEisfiwYzqRdj+OhOts6PqQ@mail.gmail.com" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">CAOxJJSdjyHjprWvM-0C8Y20dp1dtEisfiwYzqRdj+OhOts6PqQ@mail.gmail.com</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">></span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Content-Type: text/plain; charset="utf-8"</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Hello All,</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">I am trying to run my ncl script from the following shell script:</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">#!/bash/bin</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">for i in {1..2}</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">do</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">echo $i</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">ncl myfile.ncl</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">done</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Runs perfectly fine =></span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">[</span><a href="mailto:bidyut@localhost" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">bidyut@localhost</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">]$
sh<span> </span></span><a href="http://test.sh/" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">test.sh</a><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">1</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Copyright (C) 1995-2017 - All Rights Reserved</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">University Corporation for Atmospheric Research</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">NCAR Command Language Version 6.4.0</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">The use of this software is governed by a License Agreement.</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">See<span> </span></span><a href="http://www.ncl.ucar.edu/" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;color:rgb(0,120,215)" target="_blank">http://www.ncl.ucar.edu/</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline"><span> </span>for
more details.</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">(0) Hello</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">2</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Copyright (C) 1995-2017 - All Rights Reserved</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">University Corporation for Atmospheric Research</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">NCAR Command Language Version 6.4.0</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">The use of this software is governed by a License Agreement.</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">See<span> </span></span><a href="http://www.ncl.ucar.edu/" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;color:rgb(0,120,215)" target="_blank">http://www.ncl.ucar.edu/</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline"><span> </span>for
more details.</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">(0) Hello</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">But if I try to run:</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">#!/bash/bin</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">cat myfile| while read mname</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">do</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">echo "$mname"</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">echo "Running the NCL script"</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">ncl myfile.ncl</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">done</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">I get an error=></span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">[</span><a href="mailto:bidyut@localhost" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">bidyut@localhost</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">]$
sh<span> </span></span><a href="http://test1.sh/" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">test1.sh</a><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">name1</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Running the NCL script</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Copyright (C) 1995-2017 - All Rights Reserved</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">University Corporation for Atmospheric Research</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">NCAR Command Language Version 6.4.0</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">The use of this software is governed by a License Agreement.</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">See<span> </span></span><a href="http://www.ncl.ucar.edu/" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;color:rgb(0,120,215)" target="_blank">http://www.ncl.ucar.edu/</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline"><span> </span>for
more details.</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">(0) Hello</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">fatal:syntax error: line -1 before or near \n</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">name2</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">-----^</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">fatal:error in statement</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">What am I doing wrong?</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">FYI, Here are the associated file contents:</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">[</span><a href="mailto:bidyut@localhost" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">bidyut@localhost</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">]$
cat myfile</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">name1</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">name2</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">[</span><a href="mailto:bidyut@localhost" style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px" target="_blank">bidyut@localhost</a><span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">]$
cat myfile.ncl</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">begin</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">print("Hello")</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">end</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Thanks,</span><br style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px">
<span style="font-family:-apple-system,HelveticaNeue;font-size:14.6667px;display:inline">Bidyut</span><br>
</div>
<div id="gmail-m_64638788895627947ms-outlook-mobile-signature">
<div><br>
</div>
Dr. Brian Thomas<br>
Professor<br>
Physics & Astronomy<br>
Washburn University<br>
<br>
Sent from my mobile device</div>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><i><font face="georgia, serif"><b>Bidyut Bikash Goswami</b><br>Research Professor<br>Irreversible Climate Change Research Center (IRCC)</font></i><div><div><i><font face="georgia, serif">Yonsei University</font></i></div><div><i><font face="georgia, serif">Seoul, South Korea</font></i></div></div></div></div>