I have written a linux shell script for SAS users, when executed on the server it prompts the user for example, userID, appID, Authdomain. Users don't have access to the server to execute the script. I would appreciate assistance on how to write a sas program that users can input mentioned variables in SASStudio and get pushed to linux variables. I don't want the values to be hard coded. My understanding this can be done using macro variables but don't know how.
bash script when executed on the server side.
read -r SAS_SERVICES_ENDPOINT
read -r userID
read -r AdGroup
Am assuming the shell script will change to this when receiving input from sas program.
export SAS_SERVICES_ENDPOINT=&Sas_end_point
export ADGROUP=&AdGroup
export FID=&userID
export APPID=&AppID
Regards.
Will this script be executed from the SAS Studio level (in the current user SAS Studio sas session )?
Bart
Yes it will
so how about creating a macro calling X inside:
%macro runBashScript(Sas_end_point,AdGroup);
x "export SAS_SERVICES_ENDPOINT=&Sas_end_point";
x "export ADGROUP=&AdGroup";
/*
...
*/
x "/path/to/the/script/theScript.sh";
%mend;
and for user it would be:
%runBashScript(
https://enpoint.com/
,supergroup
)
to run;
Bart
I thought I had sent this, apologize for the the delay. The macro variables are not being passed to the shell script. Thoughts?
shell script variable set to
export SAS_SERVICES_ENDPOINT=$sas_end_point
export AUTHDOMAIN=$Authdomain
export ADGROUP=$AdGroup
export FID=$Fid
export APPID=$AppID
export PASSWORD=$Password
Password=$(echo -n "Password" | base64);
log of sas program, macro variables are set as below
* Set values;
%macro authUpdate(sas_end_point,AdGroup,Fid,Authdomain,AppID,Password);
x "export SAS_SERVICES_ENDPOINT=&sas_end_point";
x "export ADGROUP=&AdGroup";
x "export FID=&FID";
x "export AUTHDOMAIN=&Authdomain";
x "export USERID=&UserID";
x "export PASSWORD=&Password";
/* ... */
x "/cloud/svv001/scenarios/a_sasad/amos/set-pass-viya_Copy2.sh";
%mend;
/* User info to update authdomain */
%authUpdate(https://sasviya-dev.apps.test.net/ ,AmosNewOAuth , SASVIYA_100421-88790-PROD ,b28111 ,88821-A-SASVIYA, Password);
Shell script variables after sas program is ran. Macro variables are not passed to the shell script
+ echo
>
> + export SAS_SERVICES_ENDPOINT=
> + SAS_SERVICES_ENDPOINT=
> + export AUTHDOMAIN=
> + AUTHDOMAIN=
> + export ADGROUP=
> + ADGROUP=
> + export FID=
> + FID=
> + export APPID=
> + APPID=
> + genToken
> ++ curl -s -k /SASLogon/oauth/token -H 'Content-Type: application/x-www-form-urlencoded' -d grant_type=client_credentials -u
client-E4AA2EA2841DC958350A18D59DDCF030:b24830bc88a9ce1fd28bffe3d31ba1d0ba5398701b31ef8730dd70ac5f9de027
> ++ grep -oP '{"access_token":"\K.*?(?=",")'
> + export OAUTH_TOKEN=
> + OAUTH_TOKEN=
Giving it a try, will update.
Thank you!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: