Use programs in shared folder except ones in my home dir


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Use programs in shared folder except ones in my home dir
# 1  
Old 12-17-2015
Use programs in shared folder except ones in my home dir

I am using a cluster where all the programs are located in a shared folder (I can only read but not modify anything in this folder).
The path of the share folder is in my .bashrc file (and thus also in my $PATH - first position):
Code:
source /home/shared/bashrc

But some of the programs are outdated, so I installed the latest versions in my /home/myself/bin/ directory. To call the newest versions of the programs I have to specify the full path to my home directory (i.e. /home/myself/bin/latest_prog). If not, the cluster will use the older versions located in the shared folder by default.

Is there a way to tell the cluster to use the programs located in the shared folder EXCEPT the ones located in my /home/myself/bin/ directory?

Thanks !

Last edited by beca123456; 12-17-2015 at 03:40 PM..
# 2  
Old 12-17-2015
You can't tell the cluster to do that, but you can modify your .bashrc file on that cluster by resetting PATH after you source the shared initialization file:
Code:
source /home/shared/bashrc
PATH="$HOME/myself/bin:$PATH"

Note, however, that your post mentions /home/myself/bin and $HOME/myself/bin. On most systems, one would expect your shell initialization files to set HOME to /home/myself (not /home) assuming that your login name is myself. If this is what happens in your case, the last line above should be:
Code:
PATH="$HOME/bin:$PATH"

And, if other users on your system want to use the programs in your bin directory in their .bashrc files, they would use:
Code:
PATH="/home/myself/bin:$PATH"

since $HOME in their scripts would be their home directory; not yours.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 12-17-2015
Thanks Don Cragun !

*I edited my original post and corrected the path (/home/myself/bin/), sorry.*

If I reset PATH after sourcing the shared initialisation file as you mentioned, can I still use the shared programs without specifying their full paths?
# 4  
Old 12-17-2015
Without telling us what the shared directory is (or the shared directories are), without telling us what program names exist in those shared directory or directories, and with the only sample program name you say you have in bin directory being /home/myself/bin/latest_prog; it is hard to make a good example. Let us suppose that PATH is set by /home/shared/bashrc with:
Code:
PATH=/home/shared/bin:/bin:/usr/bin:$HOME/bin

and let us assume that the following programs are located in /home/shared/bin:
Code:
progA
progB
progC
progD

and that you have installed a newer version of progC as a file with the pathname: /home/myself/bin/progC

Then, with PATH set to:
Code:
PATH=/home/shared/bin:/bin:/usr/bin:/home/myself/bin

attempts to run progA, progB, progC and progD will run the versions found in /usr/share/bin. But, with PATH set to:
Code:
PATH=/home/myself/bin:/home/shared/bin:/bin:/usr/bin:/home/myself/bin

progA, progB, and progD will still be run from /usr/share/bin, but progC will be run from /home/myself/bin.

And, in either case, awk, cat, sed, and vi will still be run from /bin or /usr/bin (unless you install replacements for them in /usr/myself/bin or someone has installed replacements for them in /home/share/bin.
This User Gave Thanks to Don Cragun For This Post:
# 5  
Old 12-17-2015
What Don is telling you is (and this, btw., has nothing to do with the system being a cluster or not - it is simply the behavior of every shell i know of, including bash):

The PATH variable is a list of directories, separated by colon characters:

Code:
PATH=/dir/one:/dir/two:/dir/three:[....]

When you enter the name of a binary to be executed without giving any path, this list is searched from its first entry onwards, until the binary is found. With the above setting, if you enter foo as the binaries name the shell will first look for a /dir/one/foo binary. If there is none found, it will try a /dir/two/foo and so on. The catch now is that the process stops once such a binary is indeed found, so that subsequent possible matches (like a /dir/two/foo in case of an existing /dir/one/foo) will be "masked". You can still execute them if you enter the complete path, but by only entering the name without a path you get the first match along the list of directories your PATH variable contains.

This is why by simply altering your PATH variable you can state your "preferences" about which one (ofs everal possible) executables you want to have executed by default.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 6  
Old 12-17-2015
Alright, so the order of the paths in PATH matters.
Ok, I understand.

Thanks guys !
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use programs in shared folder except ones in my home dir

(0 Replies)
Discussion started by: beca123456
0 Replies

2. Programming

Shared Memory Between C Programs

I'm involved in a project with multiple teams which are developing C code for a Linux machine and we would like to have our program pass data to one of the other group's programs. The immediate idea is to have shared memory between the programs which would simply consist of variables whose size and... (2 Replies)
Discussion started by: cmcmanus3
2 Replies

3. Shell Programming and Scripting

Home dir renaming

It is required to rename the home dir of some users specifed in the file ids.csv. But the code is not working as expected. ids.csv have content in the format id1,name,id2 It displays the expected message , still it is unable to rename the dirs Find the code below: #!/bin/ksh... (3 Replies)
Discussion started by: hiten.r.chauhan
3 Replies

4. Solaris

how to change /export/home/user dir to /home /user in solaris

Hi all i am using solaris 10, i am creating user with useradd -d/home/user -m -s /bin/sh user user is created with in the following path /export/home/user (auto mount) i need the user to be created like this (/home as default home directory ) useradd -d /home/user -m -s /bin/sh... (2 Replies)
Discussion started by: kalyankalyan
2 Replies

5. UNIX for Advanced & Expert Users

Shared hosting, how to install programs and libraries in your home folder

Hi all I hope I am posting in the right section. If not please excuse me and redirect me to the right section. Here is my problem: I am using a shared hosting plan at Godady. I have shell access and of course my own folder. I would like to be able to install programs in my own folder... (4 Replies)
Discussion started by: PiniFarini
4 Replies

6. UNIX for Dummies Questions & Answers

What programs access shared library file

I was curious how to tell which programs are accessing a file (libobjc.A.dylib) in /usr/lib This file seems to be the culprit in a bunch of Safari crashes, and I just wanted to know if and what other programs use it. Also, I was curious what a good way to find out what files are being written... (4 Replies)
Discussion started by: glev2005
4 Replies

7. Shell Programming and Scripting

home dir checking

Hi, I want suggestion about user home directories, checking. how i could calculate this. I have 200 Users. if home-dir-of-user1 > 250 MB -> print "OK" fi if home-dir-of-user1 > 500 MB > Print "Warning" fi if home-dir-of-user1 > 1000 MB > Print "Critical" fi Thanks, Bash (4 Replies)
Discussion started by: learnbash
4 Replies

8. Solaris

need to restrict user to his home dir

Hello, i need to create a user who's access is restricted only to his home directory and below, i restricted his pty access by adding 'no-pty' to the options of the ssh key in authorized_keys file. However, sftp access still allows this user access to all my file system thanks (5 Replies)
Discussion started by: lidram
5 Replies

9. UNIX for Dummies Questions & Answers

root dir ? home dir ?

I am little bit confused when the words "root directory" and "home directory" and "parent directory" are used. Can anybody explains the difference. I am trying to list the names and protections levels and size of visible files in the root directory would it be correct if I just typed: ls... (2 Replies)
Discussion started by: hinman
2 Replies

10. HP-UX

Home dir for users

Hello all, Most of our users have the same home directory, I know it's weird but it has been like this before me and we don't want to change that for now. When creating a new user using command useradd, it is not allowing me to create it because it is using the home directory of someone else. I... (2 Replies)
Discussion started by: qfwfq
2 Replies
Login or Register to Ask a Question