[SAC-HELP] calling sac commands within shell scripts

Pablo Palacios p_palacios_ec at hotmail.com
Sat Oct 30 05:02:23 PDT 2010


Hi all,

Frequently I have used this instruction within or not of a loop:

sac << EOF
macro ../sac_cut.macro
EOF

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<<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:

sac <<    EOF

macro ../sac_cut.macro
   
EOF

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:

sac << EOF>/dev/null

macro ../sac_cut.macro

EOF

If you want extract results to a file:

sac << EOF>my.file


macro ../sac_cut.macro


EOF

regards,
P.


Date: Mon, 25 Oct 2010 14:21:44 -0400
From: jattanayake at gmail.com
To: sac-help at iris.washington.edu
Subject: Re: [SAC-HELP] calling sac commands within shell scripts

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.



-- 
"Nothing can start to exist nor can cease to exist, only transformation is possible"

Januka Attanayake
Solid Earth Geophysics & Economics

University of Connecticut
Beach Hall   U-2045
354,Mansfield Rd;
Storrs.CT 06269

Tel: +1 860 486 0475 (Office)
      +1 860 486 3914 (Lab - P405)
URL: http://sites.google.com/site/janukaattanayake/




_______________________________________________
sac-help mailing list
sac-help at iris.washington.edu
http://www.iris.washington.edu/mailman/listinfo/sac-help 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.iris.washington.edu/pipermail/sac-help/attachments/20101030/87b69b23/attachment.html>


More information about the sac-help mailing list