Architecting, installing and maintaining your SAS environment

PATH in X command Linux

Accepted Solution Solved
Reply
Regular Contributor
Posts: 200
Accepted Solution

PATH in X command Linux

Hi,

 

When I login to Linux i see this PATH:

 

[EUROPE\bart.heinsius-b@zew-v-0a2f0b04 ~]$ echo $PATH

/apps/sas/thirdparty/pm/9.1/bin:/apps/sas/thirdparty/pm/9.1/linux2.6-glibc2.3-x86_64/bin:/apps/sas/thirdparty/lsf/9.1/linux2.6-glibc2.3-x86_64/etc:/apps/sas/thirdparty/lsf/9.1/linux2.6-glibc2.3-x86_64/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/bin:/usr/bin:/home/bart.heinsius-b/bin

[EUROPE\bart.heinsius-b@zew-v-0a2f0b04 ~]$

 

When I submit x 'echo $PATH > /tmp/path.txt' from a SAS session running as me I see this PATH:

 

[EUROPE\bart.heinsius-b@zew-v-0a2f0b04 ~]$ cat /tmp/path.txt

/oracle/oracle-client/11.2.0.3/client/bin:/oracle/oracle-client/11.2.0.3/client/bin:/usr/bin:/bin

[EUROPE\bart.heinsius-b@zew-v-0a2f0b04 ~]$

 

Why are they different?

 

Regards,

Bart


Accepted Solutions
Solution
‎02-16-2018 04:44 AM
Regular Contributor
Posts: 200

Re: PATH in X command Linux

Posted in reply to bheinsius

I found the actual reason for this problem.

 

The SAS environment on this machine is restarted every morning using a cron scheduled task using something like this:

 

/apps/sas/SASConfig/Lev5/sas.servers stop && /apps/sas/SASConfig/Lev5/sas.servers start

 

At https://unix.stackexchange.com/questions/27289/how-can-i-run-a-cron-command-with-existing-environmen... I read this:

Cron knows nothing about your shell; it is started by the system, so it has a minimal environment. 

 

Changing the cron command to (something like) this fixed the problem:

 

/bin/bash -l -c '/apps/sas/SASConfig/Lev5/sas.servers stop && /apps/sas/SASConfig/Lev5/sas.servers start'

 

the -l (lowercase L) makes bash act as if it had been invoked as a login shell and results in the Object Spawner being started with the full sasinst path.

 

 

View solution in original post


All Replies
SAS Employee
Posts: 518

Re: PATH in X command Linux

Posted in reply to bheinsius

@bheinsius,


It appears that you have you changed PATH in /<SASHome>/SASFoundation/9.4/bin/sasenv_local

Super User
Posts: 9,925

Re: PATH in X command Linux

Posted in reply to bheinsius

A SAS session started by the spawner (ie all workspace servers used by EG or SAS Studio) inherits its environment from the spawner; this is usually that of the SAS install user.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
SAS Employee
Posts: 296

Re: PATH in X command Linux

Posted in reply to bheinsius

Do you modify $PATH in any way in <<SASHOME>>/SASFoundation/9.4/binsasenv_local ?

Regular Contributor
Posts: 200

Re: PATH in X command Linux

Posted in reply to bheinsius

My Object Spawner runs as sasinst.

This is sasinst's path:

 

[sasinst@zew-v-0a2f0b04 bin]$ echo $PATH

/apps/sas/thirdparty/pm/9.1/bin:/apps/sas/thirdparty/pm/9.1/linux2.6-glibc2.3-x86_64/bin:/apps/sas/thirdparty/lsf/9.1/linux2.6-glibc2.3-x86_64/etc:/apps/sas/thirdparty/lsf/9.1/linux2.6-glibc2.3-x86_64/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/bin:/usr/bin:/home/sasinst/bin

[sasinst@zew-v-0a2f0b04 bin]$

 

setenv_local contains these lines:

 

PATH=$ORACLE_HOME/bin:$PATH

export PATH

 

I don't see any other files in <SASHome>/SASFoundation/9.4/bin that modify the PATH:

[sasinst@zew-v-0a2f0b04 bin]$ grep PATH /apps/sas/SASHome/SASFoundation/9.4/bin/* | grep -v LIBRARY_PATH | grep -v SASCFGPATH

/apps/sas/SASHome/SASFoundation/9.4/bin/sasenv_localSmiley TongueATH=$ORACLE_HOME/bin:$PATH

/apps/sas/SASHome/SASFoundation/9.4/bin/sasenv_local:export PATH

/apps/sas/SASHome/SASFoundation/9.4/bin/sasenv_local.backup.20160216Smiley TongueATH=$ORACLE_HOME/bin:$PATH

/apps/sas/SASHome/SASFoundation/9.4/bin/sasenv_local.backup.20160216:export PATH

[sasinst@zew-v-0a2f0b04 bin]$

SAS Employee
Posts: 518

Re: PATH in X command Linux

Posted in reply to bheinsius

@bheinsius,

This is sasinst's path:
[sasinst@zew-v-0a2f0b04 bin]$ echo $PATH

 

Where were those variables defined? Profile or bashrc? Personal or global? How exactly you start the object spawner? From interactive or non-interactive shell?

For me, it seems like you have defined those variables in your personal profile but starting the object spawner in a non-interactive shell.

Super User
Posts: 9,925

Re: PATH in X command Linux

Posted in reply to bheinsius

In my case (SAS 9.4 TS1M2 on AIX 7), the PATH retrieved by

filename oscmd pipe "echo $PATH";
data _null_;
infile oscmd;
input;
put _infile_;
run;

in a workspace server session from EG is exactly the same as in the SAS install user's .profile and the same that I get when I do a su - to the SAS install user.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Regular Contributor
Posts: 200

Re: PATH in X command Linux

Posted in reply to bheinsius

Thanks for your answers and suggestions.

I solved it but i don't know why.

 

I added /usr/local/bin to the PATH setting in /home/sasinst/.bash_profile and restarted the spawner, to see if this would be picked up in the X command shell.

To my surprise I saw that not only /usr/local/bin was added to the path, but the complete path was now available in the X command shell, identical to the path I get in a regular bash shell.

I then removed /usr/local/bin from the PATH setting again and the correct path - now without /usr/local/bin - was still there.

 

It seems not to be caused by restarting the spawner because we do that every morning. Maybe an incorrect CRLF somewhere that got removed after my editing?

 

Like we say in Dutch: vraag niet hoe het kan maar profiteer ervan! (Don't ask why just take advantage of it).

 

Solution
‎02-16-2018 04:44 AM
Regular Contributor
Posts: 200

Re: PATH in X command Linux

Posted in reply to bheinsius

I found the actual reason for this problem.

 

The SAS environment on this machine is restarted every morning using a cron scheduled task using something like this:

 

/apps/sas/SASConfig/Lev5/sas.servers stop && /apps/sas/SASConfig/Lev5/sas.servers start

 

At https://unix.stackexchange.com/questions/27289/how-can-i-run-a-cron-command-with-existing-environmen... I read this:

Cron knows nothing about your shell; it is started by the system, so it has a minimal environment. 

 

Changing the cron command to (something like) this fixed the problem:

 

/bin/bash -l -c '/apps/sas/SASConfig/Lev5/sas.servers stop && /apps/sas/SASConfig/Lev5/sas.servers start'

 

the -l (lowercase L) makes bash act as if it had been invoked as a login shell and results in the Object Spawner being started with the full sasinst path.

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 703 views
  • 10 likes
  • 4 in conversation