BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gugukaka
Calcite | Level 5

In Linux, we created a shell that transfers server1 to server2. Is there a way to run .sh on SAS?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Use the macro variables to generate the command you pass to the shell the same way you would use the macro variables to generate any other SAS command you want to run.

So if you want run the unix command 

test.sh x y

And you have two macro variables named, for example, arg1 and arg2, like so:

%let arg1=x;
%let arg2=y;

Then you can generate that command like so:

test.sh &arg1. &arg2.

Personally I prefer to use a pipe to run the operating system commands, since then the program and read back any messages the command might reply with.

data _null_;
  infile "test.sh &arg1. &arg2." pipe;
  input;
  put _infile_;
run;

View solution in original post

4 REPLIES 4
Kalind_Patel
Lapis Lazuli | Level 10

Yes, You can execute the shell script in SAS Session using XCMD option, 

It might be disabled in your Workspace Server due to security concerns, so you might have to enable it, 
You can refer this link for more details about this command:
https://documentation.sas.com/?docsetId=hostunx&docsetTarget=n02699r064oqccn19vblte8xzr8m.htm&docset...

gugukaka
Calcite | Level 5

Thank you for the previous answer. One more question,
Is there a way to macro x y values in SAS when running a shell on Linux, for example sh test.sh x y?

Tom
Super User Tom
Super User

Use the macro variables to generate the command you pass to the shell the same way you would use the macro variables to generate any other SAS command you want to run.

So if you want run the unix command 

test.sh x y

And you have two macro variables named, for example, arg1 and arg2, like so:

%let arg1=x;
%let arg2=y;

Then you can generate that command like so:

test.sh &arg1. &arg2.

Personally I prefer to use a pipe to run the operating system commands, since then the program and read back any messages the command might reply with.

data _null_;
  infile "test.sh &arg1. &arg2." pipe;
  input;
  put _infile_;
run;
gugukaka
Calcite | Level 5

Thank you very much! It was what I wanted!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 3528 views
  • 0 likes
  • 3 in conversation