Run Unix command (to Switch the user from current to different) from PCSAS

Reply
Occasional Contributor
Posts: 19

Run Unix command (to Switch the user from current to different) from PCSAS

Hi,

 

I have around 20 SAS programs to run one after the other and I will run them from PC SAS remotely using RSUBMIT AND ENDRSUBMIT. After running 5 steps, I need to switch the user and then run step 6(Isince I can't run step 6 using my user access). please suggest how to switch the user in UNIX server from PC SAS so that I will run the step 6 and then come back to same user to run rest of the steps from step7.

 

Thanks,

Hari.

Super User
Posts: 19,817

Re: Run Unix command (to Switch the user from current to different) from PCSAS

Do you have X command permissions? Can you pass commands to your OS?

Occasional Contributor
Posts: 19

Re: Run Unix command (to Switch the user from current to different) from PCSAS

Hi,

 

I think I have . I ran this code just to confirm whether the code I am running is getting created from newuser or my user. But, the dataset ss.mm1 is getting created from my user.

 

rsubmit;

x "su - newuser";

libname ss 'xxxxxxxxxx';

data ss.mm1;

set ss.mm(obs=1);

run;

endrsubmit;

Super User
Super User
Posts: 7,059

Re: Run Unix command (to Switch the user from current to different) from PCSAS

From your description you are running one program on your PC that is using RSUBMIT to run some steps on a remote computer.

So if you want some of the steps run using userid one and others using userid two then just make two connections to the remote computer. Something like this.

 

signon remote1;
rsubmit remote1;
* program 1;
endrsubmit;
rsubmit remote1;
* program 2;
endrsubmit;

...
signoff remote1;
signon remote2;
rsubmit remote2;
* program 6;
endrsubmit;
Occasional Contributor
Posts: 19

Re: Run Unix command (to Switch the user from current to different) from PCSAS

[ Edited ]

Hi Tom,

 

Thanks.

 

This seems, it will work out in my scenario. But one thing, I will use a SAS script to connect to UNIX server and I will provide my userid and password and I will be able to connect. but, at step 6, where I need to swith the user that's super user and I wont have PW (I can only switch to that user as I have access). now, if I run sas script in between to login with new user, I wont have PW. So how to overcome this.

do we get any sas script to login as password less login or should I make any settings to my ID to not to ask PW for that super user ?

Super User
Super User
Posts: 7,059

Re: Run Unix command (to Switch the user from current to different) from PCSAS

[ Edited ]

So it sounds like you need to (1) connect to server as you (2) run some command to switch to the captive account (3) launch SAS.

 

In the old days we used to use signon scripts that told SAS how to make the connection.  So you could just edit the script and add code for step (2) between the signon process and the launch SAS command.

 

Or you could create a command that combines (2) and (3) and then call that command to launch SAS instead of the default command you normally use to launch SAS.

Occasional Contributor
Posts: 19

Re: Run Unix command (to Switch the user from current to different) from PCSAS

[ Edited ]

Hi Tom,

 

    1. Even I run Signon script from PC SAS to login to sasgrid1(Unix  SAS Server) and I will provide my Username & PW.

    2. After running 5 steps, I need to swith the user in the smae SAS Server to run next step.

 

    So here, is there a way to Swith user from the same SAS session instead of Sifnoff from my user and again run Signon script to login with super user ? Becasue after step 6, again I have to run next 3 steps from my user and then from step 10 again I have to swith to super user, for 11-20 again I have to run from my user. So, switching back and forth is a bit difficult as I am automationg the process and we dont want to wait at system and give credentials when ever it asks to Switch the user.

 

Please provide your comments.

Super Contributor
Posts: 440

Re: Run Unix command (to Switch the user from current to different) from PCSAS

Your PC session can be connected to more than one remote session at the same time although when issuing your signon, signoff and rsubmit you have to name the sessions. You also have to coordinate their timings with the waitfor statement. Example 4 at this link shows you how it's done.

 

So at the start of your run you log on twice - once as your normal user and once as your super user. Your program should rsubmit to your normal user session until you hit the part where you want to run as the super user. You then rsubmit that to your super user session. I've run multiple sessions at the same time using this technique a lot - it's easy once you get the hang of it.

Occasional Contributor
Posts: 19

Re: Run Unix command (to Switch the user from current to different) from PCSAS

Posted in reply to ChrisBrooks

Hi Chris,

 

Thanks very much. I will work on your suggetion.

 

If possible, can you send the piece of code to signon to server from PC sas. I will just refer it and make updates as required.

Respected Advisor
Posts: 4,173

Re: Run Unix command (to Switch the user from current to different) from PCSAS

@Hari2

I had years ago a use case where I couldn't directly connect to server B but I could connect to server A and then from server A connect to server B. This was possible by nesting rsubmit blocks - the outer rsubmit connected to server A and then within this rsubmit was another nested rsubmit block which connected to server B.

I guess you could use the exactly same approach for your use case.

 

I don't remember anymore if we had to mask the inner rsubmit block so that it only got executed on the server A or if this works without any masking. But I know that this is an approach which will work.

Super Contributor
Posts: 440

Re: Run Unix command (to Switch the user from current to different) from PCSAS

This is a good example - except sign on as different users https://support.sas.com/rnd/scalability/tricks/connect.html
Ask a Question
Discussion stats
  • 10 replies
  • 184 views
  • 0 likes
  • 5 in conversation