<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi all,<br><br>Frequently I have used this instruction within or not of a loop:<br><br>sac &lt;&lt; EOF<br>macro ../sac_cut.macro<br>EOF<br><br>EOF (end of file, or what ever other string) is used to identify or close the end of sac (or other program like matlab or R) intructions. Between sac&lt;&lt;EOF and EOF you can put sac instructions. But you must care dont put space or tabs before the onset of each line, usually done when we put code within a loop. If EOF has, for instance, 3 spaces before EOF, the open intruction of sac must have them:<br><br>sac &lt;&lt; &nbsp;&nbsp; EOF<br>
macro ../sac_cut.macro<br>&nbsp;&nbsp;&nbsp;
EOF<br><br>I am using cshell. I have not tested in other type of shell. If you dont want echo of the process you can use this:<br><br>sac &lt;&lt; EOF&gt;/dev/null<br>
macro ../sac_cut.macro<br>
EOF<br><br>If you want extract results to a file:<br><br>sac &lt;&lt; EOF&gt;my.file<br>

macro ../sac_cut.macro<br>

EOF<br><br>regards,<br>P.<br><br><br><hr id="stopSpelling">Date: Mon, 25 Oct 2010 14:21:44 -0400<br>From: jattanayake@gmail.com<br>To: sac-help@iris.washington.edu<br>Subject: Re: [SAC-HELP] calling sac commands within shell scripts<br><br>Hi again, <br>I've had a couple of responses from the members, thanks for your time! However, none of them worked. I still get the same error. I am calling sac within a while read line loop. Should there be a special way of calling sac and executing commands if I do it in a loop? I haven't come across this problem with other programs like GMT and taup at all.<br>
<br>my error msg: SAC&gt; readline: readline_callback_read_char() called with no handler!<br><br>and bash script:<br><br>while read line<br>do<br>&nbsp;&nbsp;&nbsp; cd $line<br>&nbsp;&nbsp; <br>&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; sac<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; gawk '{print "macro ../sac_cut.macro"}'<br>
<br>&nbsp;&nbsp;&nbsp; cd ../<br>
done &lt; folder_list.txt <br><br>commands I've tried so far:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (1) echo -e "macro ../sac_cut.macro" | sac<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (2) sac &lt;&lt; EOF and&nbsp; !<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; macro ../sac_cut.macro<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; EOF and !&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ==&gt; doesn't work within a while loop<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (3) printf  "macro ../sac_cut.macro" | sac<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (4) echo  "macro ../sac_cut.macro" | sac<br><br><br>Thanks again !<br><br>Januka.<br><br><div class="ecxgmail_quote">On Mon, Oct 25, 2010 at 12:20 PM, Januka Attanayake <span dir="ltr">&lt;<a href="mailto:jattanayake@gmail.com">jattanayake@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="ecxgmail_quote" style="padding-left: 1ex;">Greetings, <br>I am trying to call sac within a shell script as follows. <br><br>while read line<br>
do<br>&nbsp;&nbsp;&nbsp; cd $line<br>&nbsp;&nbsp; <br>&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; sac<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; gawk '{print "macro ../sac_cut.macro"}'<br><br>&nbsp;&nbsp;&nbsp; cd ../<br>
done &lt; folder_list.txt <br><br><br>folder_list.txt holds the names of all the directory names that the script is suppose to look in. <br>I see that sac is initiated but the problem is in executing commands within sac once it is initiated. I have tried several ways of doing that including printf and piping to sac with back quotes. Still I get the following error. <br>

<br>SAC&gt; readline: readline_callback_read_char() called with no handler!<br><br>How should one execute sac commands within a shell script? <br><br>I am using sac Version 101.3b<br><br>Thanks a lot.<br><font color="#888888"><br>
Januka.<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>"Nothing can start to exist nor can cease to exist, only transformation is possible"<br><br>Januka Attanayake<br>Solid Earth Geophysics &amp; Economics<br>
University of Connecticut<br>Beach Hall&nbsp;&nbsp; U-2045<br>354,Mansfield Rd;<br>Storrs.CT 06269<br><br>Tel: +1 860 486 0475 (Office)<br>&nbsp; &nbsp; &nbsp; +1 860 486 3914 (Lab - P405)<br>URL: <a href="http://sites.google.com/site/janukaattanayake/" target="_blank">http://sites.google.com/site/janukaattanayake/</a><br>
<br>
<br>_______________________________________________
sac-help mailing list
sac-help@iris.washington.edu
http://www.iris.washington.edu/mailman/listinfo/sac-help                                               </body>
</html>