[SAC-HELP] calling sac commands within shell scripts
Onur Tan
Onur.Tan at mam.gov.tr
Mon Oct 25 11:45:29 PDT 2010
Hi ,
This Cshell script may run (I cannot test at this time) .
the file a.csh :
----
foreach dir ( ` cat folder_list.txt ` ) # note that there two backquotes
cd $dir
echo macro ../sac_cut.macro > macro.tmp # the last line of the sac_cut.macro must be ‘exit’ to quit from sac
sac < macro.tmp
cd ..
end
\rm tmp
----
to run type
> csh a.csh
Dr. Onur TAN
---------------------------------------------- 40.7866N 29.4500E ---------
TÜBİTAK Marmara Araştırma Merkezi, Yer ve Deniz Bilimleri Enstitüsü
TUBITAK Marmara Research Center, Earth and Marine Sciences Institute
Gebze - Kocaeli - TURKEY
On 25.10.2010 21:21, "Januka Attanayake" <jattanayake at gmail.com> wrote:
Hi again,
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.
my error msg: SAC> readline: readline_callback_read_char() called with no handler!
and bash script:
while read line
do
cd $line
sac
gawk '{print "macro ../sac_cut.macro"}'
cd ../
done < folder_list.txt
commands I've tried so far:
(1) echo -e "macro ../sac_cut.macro" | sac
(2) sac << EOF and !
macro ../sac_cut.macro
EOF and ! ==> doesn't work within a while loop
(3) printf "macro ../sac_cut.macro" | sac
(4) echo "macro ../sac_cut.macro" | sac
Thanks again !
Januka.
On Mon, Oct 25, 2010 at 12:20 PM, Januka Attanayake <jattanayake at gmail.com> wrote:
Greetings,
I am trying to call sac within a shell script as follows.
while read line
do
cd $line
sac
gawk '{print "macro ../sac_cut.macro"}'
cd ../
done < folder_list.txt
folder_list.txt holds the names of all the directory names that the script is suppose to look in.
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.
SAC> readline: readline_callback_read_char() called with no handler!
How should one execute sac commands within a shell script?
I am using sac Version 101.3b
Thanks a lot.
Januka.
More information about the sac-help
mailing list