[SAC-HELP] SC (System Command) using an escape character (@) in a macro does not work
Frederik Tilmann
tilmann at esc.cam.ac.uk
Thu Mar 15 03:50:30 PDT 2007
Nancy
the first example works for me, too. The second example does not work
because (I think; sac-devs can correct me if I am wrong)
1. Each sc command runs in its own shell; i.e. there is no way you can
recover shell variables set in one run of sc in the next sc command as
the corresponding shell would have been closed.
2. sh rather than csh is used for execution. In sh, variables which are
not set expand to nothing
As a workaround you can use this somewhat awkward construction:
SAC> sc echo 'set info = `cat xx` ; echo x @$info x' | csh
I suspect event the following would work bypasssing the need for a temp file
SAC> sc echo 'set info = `grep 6.0_8.0 %file_vel%` ; echo x @$info x' | csh
which explicitly uses csh by piping into it.
Regards
Frederik
Nancy_Collins at urscorp.com wrote:
> I am using some SAC applications that have been developed elsewhere and
> work on SunOS Unix. I am running sac2000 on SunOS 5.8.
>
> I have a problem when a macro issues a "system command" (sc) that needs
> an escape character before a character that would otherwise be
> interpreted by SAC. The command that is passed to Unix does have the
> escape character removed but it is not interpreted correctly by Unix.
>
> For example, the following command returns an syntax error for the awk
> portion of it:
>
> *sc grep 6.0_8.0 %file_vel% | awk '{print "setbb v0 " @$3}' > junk; m junk*
>
> As a simpler test is issued the following set of commands from within SAC:
>
> *sc grep 6.0_8.0 %file_vel%** > xx*
> * sc cat xx*
> * sc set info = `cat xx`*
> * sc echo @$info*
>
> The 2nd line, the "cat xx" does print the contents of the file xx
> correctly but the 4th line only prints a blank line, not the contents of
> the variable info. When I do the same thing outside of SAC at the system
> prompt, the variable info contains the contents of the file xx.
>
> Any guidance would be appreciated.
>
> Nancy
> -----------------------------------
> Nancy F. Collins
> URS Corporation
> 566 El Dorado Street, Suite 200
> Pasadena, CA 91101
> (626) 449-7650; FAX (626) 449-3536
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> sac-help mailing list
> sac-help at iris.washington.edu
> http://www.iris.washington.edu/mailman/listinfo/sac-help
--
Frederik Tilmann
Bullard Laboratories Tel. +44 1223 765545
Department of Earth Sciences Fax. +44 1223 360779
University of Cambridge email: tilmann at esc.cam.ac.uk
Madingley Road
Cambridge CB3 0EZ
UK
More information about the sac-help
mailing list