- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Will this script be executed from the SAS Studio level (in the current user SAS Studio sas session )?
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes it will
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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=
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Giving it a try, will update.
Thank you!