Thread: select waveform with sac

Started: 2011-11-10 20:15:00
Last activity: 2011-11-10 20:15:00
Topics: SAC Help
Xuzhang Shen
2011-11-10 20:15:00
Hello everyone,
I met a question to select waveform with sac. I hope I can check the waveform and save some good data in a folder or put bad data in another folder. The following is the part of my shell script.
for fil in *.SAC
do
sac <<ENDD
qdp off
ygrid on
r AA.SAC
p1
setbb resp (REPLY "Enter t to trash the file ")
if %resp eq "t" then
sc mv AA.SAC Trash
endif
q
ENDD
done
After excuting the shell script, there was no any pause and just put the *.SAC into the Trash folder. What' s problem in my script and how to solve it.
Thank you.
Cheers, Xuzhang

2011-11-10

  • George Helffrich
    2011-11-10 13:30:57
    Dear Xuzhang -

    SAC is reading input from the shell script, not your terminal. It is probably giving an end-of-file to the REPLY function.
    Use a review procedure structured like this:

    # Define sac macro called /tmp/view.m
    cat << 'EOF' > /tmp/view.m
    message "Processing $1$"
    read $1$
    setbb resp "(reply Enter t to trash the file)"
    if _%resp% eq _t
    sc mv $1$ Trash
    endif
    'EOF'
    # Create sac input file
    ls *.SAC | awk '{print "m /tmp/view.m",$1}' > /tmp/sac.in
    # Run SAC once, process all files
    sac
    qdp off
    ygrid on
    message "Many questions about files will happen now ..."
    m /tmp/sac.in
    quit

    On 10 Nov 2011, at 04:15, shenxzh<at>gmail.com wrote:

    Hello everyone,
    I met a question to select waveform with sac. I hope I can check the waveform and save some good data in a folder or put bad data in another folder. The following is the part of my shell script.
    for fil in *.SAC
    do
    sac <<ENDD
    qdp off
    ygrid on
    r AA.SAC
    p1
    setbb resp (REPLY "Enter t to trash the file ")
    if %resp eq "t" then
    sc mv AA.SAC Trash
    endif
    q
    ENDD
    done
    After excuting the shell script, there was no any pause and just put the *.SAC into the Trash folder. What' s problem in my script and how to solve it.
    Thank you.
    Cheers, Xuzhang

    2011-11-10
    _______________________________________________
    sac-help mailing list
    sac-help<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-help



    George Helffrich
    george.helffrich<at>bris.ac.uk



Page built 20:48:55 | v.b'108166