sas_usermods.sh

Reply
Contributor
Posts: 27

sas_usermods.sh

Has anyone been able to pass the value of a Unix environment variable set in SASApp/sas_usermods.sh to an EG session? 

From /sasapps/dev/ServerConfig/Lev1/SASApp/sas_usermods.sh :

export TESTSTR=from_SASApp_sas_usermods.sh

Statements run using SASApp in EG:

%put &_SASSERVERNAME ;

%put %sysget(USER) ;

%put %sysget(PWD) ;

%put %sysget(TESTSTR) ;

%put %sysget(HOSTNAME) ;

Results in EG log:

29         %put &_SASSERVERNAME ;

'SASApp'

30         %put %sysget(USER) ;

afarrer

31         %put %sysget(PWD) ;

/sasapps/dev/ServerConfig/Lev1/SASApp

32         %put %sysget(TESTSTR) ;

WARNING: The argument to macro function %SYSGET is not defined as a system variable.

33         %put %sysget(HOSTNAME) ;

dc4coj

I have not traced through everything yet but hoping someone has got this working

Contributor
Posts: 27

Re: sas_usermods.sh

I need to review my understanding of export under /bin/sh as $TESTSTR is not known outside the shell script:

$ /sasapps/dev/ServerConfig/Lev1/SASApp/sas_usermods.sh

$ echo $TESTSTR

$

Whereas, this is fine:

$ export MYSTR=sometext

$ echo $MYSTR

sometext

Contributor
Posts: 27

Re: sas_usermods.sh

Got it! The environment variable needs to be set one level higher in SASApp/appservercontext_env_usermods.sh so it is available to subsequent shells:

31         %put %sysget(PWD) ;

/sasapps/dev/ServerConfig/Lev1/SASApp

32         %put %sysget(TESTSTR) ;

from_SASApp_appservercontext_env_usermods.sh

Does anyone else think this statement in sas_usermods.sh is unhelpful ? :

# This script extends sas.sh.  Add local environment variables

# to this file so they will be preserved.

Ask a Question
Discussion stats
  • 2 replies
  • 288 views
  • 0 likes
  • 1 in conversation