LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2011, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 20 Jan 2011 02:43:06 -0500
Reply-To:     Scott Bass <sas_l_739@YAHOO.COM.AU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Scott Bass <sas_l_739@YAHOO.COM.AU>
Subject:      Re: Unix scripting question: keeping -sysparm quoted

Hi,

I've gotten this to work thanks to a private email (you know who you are ;-) )

In case others have this issue in the future, see additional comments inline below.

Regards, Scott

On Tue, 18 Jan 2011 21:45:26 -0500, Scott Bass <sas_l_739@YAHOO.COM.AU> wrote:

>Hi, > >This question is specific to Unix. If you're not working with SAS on Unix >just hit delete or ignore. > >Summary: I have a series of Unix scripts nested about 4 deep. I need to >set the -sysparm parameter from the top level script to control the >processing of the SAS program. The quoting of -sysparm is not being >maintained properly, and SAS issues an error. > >Details: I have the following scripts: > >RunAll_DDB.sh: This is the top level script ("one liner"): > >./RunAll.sh RunAllUnix_DDB.sas "$@"

The design of this series of scripts is: RunAll.sh is a utility script that takes two arguments:

1) The name of a SAS program 2) Parameters passed to the SAS program via -sysparm (optional). These parameters are names of files to execute. The SAS program handles any error checking, so I'm happy with no error checking in the scripts. "Bad" parameters passed in via -sysparm are simply ignored.

> >RunAll.sh: This is used for a variety of SAS prgrams: > >pgm=$1 >shift > >if [[ $# -gt 0 ]]; then sysparm="-sysparm \"$@\""; else sysparm=""; fi > >print \ >sas -sysin $pgm $sysparm -rsasuser -noterminal >sas -sysin $pgm $sysparm -rsasuser -noterminal

I changed this to:

if [[ $# -gt 0 ]]; then sysparm="-sysparm"; else sysparm=""; fi

print \ sas -sysin $pgm $sysparm "$*" -rsasuser -noterminal sas -sysin $pgm $sysparm "$*" -rsasuser -noterminal

instead of trying to escape embedded quotation marks as before.

Sometimes it just takes another set of eyes to see the obvious!!!

> >The "sas" script: This is a local script: > >#!/usr/bin/ksh >[[ $TERM = "vt220" ]] && TERM="vt220-nam" >if [[ $SAS_ROOT != "/sas913" ]] >then > echo "SAS directory $SAS_ROOT is invalid for this server" > exit 1 >fi >SAS_CONFIG="$SAS_ROOT/sasv9.cfg" >if [ ! "$DISPLAY" ] >then > SAS_OPTIONS=$SAS_OPTIONS" -NODMS" >fi >echo $@ >SAS_WORK="$(saswork)" > >#export SAS_ROOT SAS_WORK > >echo "$SAS_ROOT/sas $SAS_OPTIONS -work $SAS_WORK $@" >$SAS_ROOT/sas $SAS_OPTIONS -work $SAS_WORK $@ > >(Note: I've also overridden that "sas" script with my own, trying: > >$SAS_ROOT/sas $SAS_OPTIONS -work $SAS_WORK "$@" >$SAS_ROOT/sas $SAS_OPTIONS -work $SAS_WORK $* >$SAS_ROOT/sas $SAS_OPTIONS -work $SAS_WORK "$*" >

I changed this to:

$SAS_ROOT/sas $SAS_OPTIONS -work $SAS_WORK "$@"

These changes enabled to processing to work. The "echo" statements to the console don't show the sysparm value as being quoted, but &sysparm is correct in the SAS program, and the program functions properly.

> >$SAS_ROOT/sas is SAS's script. At my site it is installed in /sas913/sas. >I won't print the entire file, but it contains the line: > ># This is a generated script. Do not edit this file. > >then later, the business end of the script... > >exec $SAS_INSTALL_ROOT/hotfix/sasexe/sas "$@" > > >Sorry for all the details - hopefully it makes sense to someone out there!!! > >The various "echo" commands display this in my shell: > >RunAllUnix_DDB.sh d4* (I want to run all the d4* programs) >sas -sysin RunAllUnix_DDB.sas -sysparm "d4xxxx.sas d4yyyy.sas d4zzzz.sas" >-rsasuser -noterminal >\-sysin RunAllUnix_DDB.sas -sysparm "d4xxxx.sas d4yyyy.sas d4zzzz.sas" >-rsasuser -noterminal >/sas913/sas -autoexec /proj/some/pharma/company/autoexec.sas -work >/saswork/tmp7 -sysin RunAllUnix_DDB.sas -sysparm "d4xxxx.sas d4yyyy.sas >d4zzzz.sas" -rsasuser -noterminal >ERROR: Invalid file, /proj/some/pharma/company/programs/d4zzzz.sas".sas. > >Everything *looks* OK in the shell output - sysparm stays quoted throughout >the script invocations (or at least the "echo" statements). But, the final >error message is indicative of -sysparm not being "really" quoted. > >If I cut-and-paste the final SAS command line and submit it directly in the >shell, the command works fine. > >Does anyone know how to maintain the quoting of the -sysparm argument >throughout a series of nested scripts? > >Thanks, >Scott


Back to: Top of message | Previous page | Main SAS-L page