For the following please consider that I'm new to the Linux file system and have little understanding here.

When I log onto my cluster I do so on a default machine. The admin have setup several python distributions in the root and I've set the one that I want to use in my .bashrc. In my case and for illustration this distribution is:

export PATH="/csoft/epd-7.3.2/bin:$PATH";

I've been asked to execute scripts from another machine that I have to ssh to via the terminal. When I ssh to this machine that file system appears exactly the same (including the .bashrc). However, a different version of python is executed by default. How do I set the path for this ssh machine, those unique name can be determined via hostname?

  • "the path" meaning: "how do I execute a specific version of python"? – Jeff Schaller Oct 14 '17 at 21:29
  • is the file path relative to the root. In my case: – Peter Bingham Oct 14 '17 at 21:32
  • export PATH="/csoft/epd-7.3.2/bin:$PATH"; in the .bashrc. This is the path to the python that I need. The sys admins have several other python distributions that you can choose by setting this path appropriately. – Peter Bingham Oct 14 '17 at 21:33
  • so you need that particular $PATH set on a particular machine? Does hostname or uname -n return a unique value on that "other" machine that will uniquely identify it? – Jeff Schaller Oct 14 '17 at 21:35
  • Yes it does have a unique name. – Peter Bingham Oct 14 '17 at 21:37

In your .bash_profile, include this (replacing unique-hostname-here with the output from uname -n on that host):

case $(uname -n) in
  (unique-hostname-here) PATH="/csoft/epd-7.3.2/bin:$PATH"

This presumes that the PATH variable has already been populated and exported previously (or subsequently); no need to re-export it every time it's set.

Further reading on shell initialization files:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.