Thread: SAC and sh issue

Started: 2021-06-18 14:45:11
Last activity: 2021-06-19 13:53:38
Topics: SAC Help
Ray Russo
2021-06-18 14:45:11
Hi -

I'm trying to use a SAC macro+sh script that dates back decades, ttsac.
Here's the issue, which as far as I know is specific to the recent SAC 102
release.

The macro calls the shell script and the shellscript is supposed to write
drop files to /tmp for later use by plotc. However, the shell script
generates only an empty file, /tmp/ttsac.pcf. The problem exists for both
my long-in-the-tooth personal version and George's version from the SACbook
github site.

Operative lines of code are:

*macro: *

* Build annotation information for display and limits in macro ./ttsac.xlim
$run /Users/ray/splitting/macros/ttsac.sh
.
.
.
* Generate plot, then annotate it
bf;p1;plotc replay file ./ttsac;ef

*sh script:*

file=./ttsac.pcf
.
.
.
cat /dev/null > $file
.
.
.
echo '[f3hcvbss]' >> $file
etc.

The file /tmp/ttsac.pcf is created, but none of the subsequent echo
commands writes anything to the file.

I've attempted lots of fixes, but no joy.

Any ideas?

Thanks,

Ray

--
R. M. Russo
Associate Professor, Graduate Coordinator
Department of Geological Science
University of Florida
Gainesville, FL 32611 USA
+1 352 392 6766
+1 352 392 9294 fax
rrusso<at>ufl.edu for all University of Florida business
rmrusso2010<at>gmail.com for all other contacts

  • Leigh House
    2021-06-19 11:04:10
    Ray,

    This may not be a SAC problem.

    Do you have write permission for the file? Is the file actually in the location you intend it to be?

    File “ttsac.pcf" will be put in the current directory, because of the leading ./ in the name in line

    file=./ttsac.pcf

    Also, I don’t use ’sh’, but I’m puzzled by the purpose of the line

    cat /dev/null > $file

    With csh, if the file does not exist, it will be created by the line

    echo '[f3hcvbss]' >> $file

    And if you want to assure you are not appending to an existing file, why not delete the file first? If the file does not exist, “rm” will just complain, but so what?

    Except for the ./ putting the file into the current directory, the script should work. Provided the file is writable. If it isn’t writable, you should get a Permission denied message.

    If you make up a simple sequence of steps for the shell script, you may be able to enter each line individually and verify you have the result you want.

    Good luck,

    Leigh

    On Jun 18, 2021, at 12:46 PM, Ray Russo (via IRIS) <sac-help-bounce<at>lists.ds.iris.edu> wrote:

    Hi -

    I'm trying to use a SAC macro+sh script that dates back decades, ttsac. Here's the issue, which as far as I know is specific to the recent SAC 102 release.

    The macro calls the shell script and the shellscript is supposed to write drop files to /tmp for later use by plotc. However, the shell script generates only an empty file, /tmp/ttsac.pcf. The problem exists for both my long-in-the-tooth personal version and George's version from the SACbook github site.

    Operative lines of code are:

    macro:

    * Build annotation information for display and limits in macro ./ttsac.xlim
    $run /Users/ray/splitting/macros/ttsac.sh
    .
    .
    .
    * Generate plot, then annotate it
    bf;p1;plotc replay file ./ttsac;ef

    sh script:

    file=./ttsac.pcf
    .
    .
    .
    cat /dev/null > $file
    .
    .
    .
    echo '[f3hcvbss]' >> $file
    etc.

    The file /tmp/ttsac.pcf is created, but none of the subsequent echo commands writes anything to the file.

    I've attempted lots of fixes, but no joy.

    Any ideas?

    Thanks,

    Ray

    --
    R. M. Russo
    Associate Professor, Graduate Coordinator
    Department of Geological Science
    University of Florida
    Gainesville, FL 32611 USA
    +1 352 392 6766
    +1 352 392 9294 fax
    rrusso<at>ufl.edu for all University of Florida business
    rmrusso2010<at>gmail.com for all other contacts


    ----------------------
    SAC Help
    Topic home: http://ds.iris.edu/message-center/topic/sac-help/ | Unsubscribe: sac-help-unsubscribe<at>lists.ds.iris.edu

    Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
    Update subscription preferences at http://ds.iris.edu/account/profile/



    • Ray Russo
      2021-06-19 13:53:38
      Hi Leigh -

      Thanks for your response! I do have permission to write in the directory
      in which I'm running sac, the macro and the shellscript; also for /tmp. A
      zero-length (empty) file ttsac.pcf is created there; same outcome when I
      try the original write to /tmp/ttsac.pcf.

      George wrote me offline with some suggestions that I have yet to try. His
      take was that the echo was sending its arguments to destinations unknown
      because stdio was not setting properly; or that a "cd" command was not
      setting properly.

      I'll come back to the listserve once I've got it figured out.

      Best,

      Ray



      On Sat, Jun 19, 2021 at 1:04 PM Leigh House <hagar<at>newmexico.com> wrote:

      Ray,

      This may not be a SAC problem.

      Do you have write permission for the file? Is the file actually in the
      location you intend it to be?

      File “ttsac.pcf" will be put in the current directory, because of the
      leading ./ in the name in line

      file=./ttsac.pcf

      Also, I don’t use ’sh’, but I’m puzzled by the purpose of the line

      cat /dev/null > $file

      With csh, if the file does not exist, it will be created by the line

      echo '[f3hcvbss]' >> $file

      And if you want to assure you are not appending to an existing file, why
      not delete the file first? If the file does not exist, “rm” will just
      complain, but so what?

      Except for the ./ putting the file into the current directory, the script
      should work. Provided the file is writable. If it isn’t writable, you
      should get a Permission denied message.

      If you make up a simple sequence of steps for the shell script, you may be
      able to enter each line individually and verify you have the result you
      want.

      Good luck,

      Leigh

      On Jun 18, 2021, at 12:46 PM, Ray Russo (via IRIS) <
      sac-help-bounce<at>lists.ds.iris.edu> wrote:

      Hi -

      I'm trying to use a SAC macro+sh script that dates back decades, ttsac.
      Here's the issue, which as far as I know is specific to the recent SAC 102
      release.

      The macro calls the shell script and the shellscript is supposed to
      write drop files to /tmp for later use by plotc. However, the shell script
      generates only an empty file, /tmp/ttsac.pcf. The problem exists for both
      my long-in-the-tooth personal version and George's version from the SACbook
      github site.

      Operative lines of code are:

      macro:

      * Build annotation information for display and limits in macro
      ./ttsac.xlim
      $run /Users/ray/splitting/macros/ttsac.sh
      .
      .
      .
      * Generate plot, then annotate it
      bf;p1;plotc replay file ./ttsac;ef

      sh script:

      file=./ttsac.pcf
      .
      .
      .
      cat /dev/null > $file
      .
      .
      .
      echo '[f3hcvbss]' >> $file
      etc.

      The file /tmp/ttsac.pcf is created, but none of the subsequent echo
      commands writes anything to the file.

      I've attempted lots of fixes, but no joy.

      Any ideas?

      Thanks,

      Ray

      --
      R. M. Russo
      Associate Professor, Graduate Coordinator
      Department of Geological Science
      University of Florida
      Gainesville, FL 32611 USA
      +1 352 392 6766
      +1 352 392 9294 fax
      rrusso<at>ufl.edu for all University of Florida business
      rmrusso2010<at>gmail.com for all other contacts


      ----------------------
      SAC Help
      Topic home: http://ds.iris.edu/message-center/topic/sac-help/ |
      Unsubscribe: sac-help-unsubscribe<at>lists.ds.iris.edu

      Sent from the IRIS Message Center (http://ds.iris.edu/message-center/)
      Update subscription preferences at http://ds.iris.edu/account/profile/



      --
      R. M. Russo
      Associate Professor, Graduate Coordinator
      Department of Geological Science
      University of Florida
      Gainesville, FL 32611 USA
      +1 352 392 6766
      +1 352 392 9294 fax
      rrusso<at>ufl.edu for all University of Florida business
      rmrusso2010<at>gmail.com for all other contacts

01:27:04 v.22510d55