Thread: using sac within a perl script

Started: 2007-10-25 17:09:35
Last activity: 2007-10-25 19:39:33
Topics: SAC Help
Gavin Hayes
2007-10-25 17:09:35
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";

  • Brian Savage
    2007-10-25 19:39:33
    Gavin,

    Try adding in a

    print SAC "quit\n";

    following the foreach loop.
    This bug is due to the line editing capability which was added in to
    SAC recently.

    It is on the list of things to fix.

    Cheers
    Brian

    On Oct 25, 2007, at 12:09 PM , Gavin Hayes wrote:

    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";
    _______________________________________________
    sac-help mailing list
    sac-help<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-help


09:07:47 v.22510d55