[SAC-HELP] using sac within a perl script

Gavin Hayes ghayes at usgs.gov
Thu Oct 25 09:09:35 PDT 2007


All,
    I was hoping someone might be able to help me understand a  
problem I'm having calling sac within a perl script, and using a  
'foreach' loop to edit a list of files. When I run the following  
script on a linux machine (running sac2000, version 00.59.48), it  
runs fine and exits without problems. When I run the same script on  
an Intel macPro (running sac version 101.0), the script hangs within  
the foreach loop after processing the last file in the list and does  
not exit sac.
   Interestingly, if I run the same script on a PowerPC macbook  
(running sac version 100.0), the script also works. Does anyone have  
a suggestion for how to fix the problem on the Intel mac? Thanks for  
the help,

Gavin Hayes


#!usr/bin/perl -w
#
$sac="/Applications/sac/bin/sac";
$io_head=1;
if($io_head==1){
    @files=<*.sac>;
    open (SAC, "|$sac");
    foreach my $STA (@files) {
         print SAC "r $STA\n";
         print SAC "ch user8 999\n";
         print SAC "w over\n";
         print SAC "lh user8\n";
         print "$STA\n";
    }
close(SAC);
print "Closed SAC";



More information about the sac-help mailing list