PATH dircetory search order


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PATH dircetory search order
# 1  
Old 12-31-2008
PATH directory search order

Hello

I using CygWin and am working on project that requires whereby after I make some code changes and rebuild I have to manually copy the updated files into the install directory to test them. There is a build output directory where these files placed, but the program will not run from there. It is mainly dll files that need updating.

So I thought if I set up my path with the build output directory as the first path my program might search there first, and thereby find the updated dll if there is one.

I tried changing my PATH using the following script something like:

PATH="/cygdrive/d/dev/Builds/BuildOutputDir:.:"

However, no matter what I do my application always seems to use the dll from the install directory if there is one. If I remove the dll from that directory and test by setting a few other directories in the PATH then I can see that the precedence of the directories is working correctly. Just I cannot remove the working directory... Smilie

Is what I am trying to do possible? Is what I set my PATH to correct?

Thanks in advance for your help. Smilie

Last edited by bobban; 12-31-2008 at 10:36 PM..
# 2  
Old 01-01-2009
Just a quick comment. I occasionally use cygwin but don't know how close to a real unix shell it is.

1-With a real shell the directories are searched in the order they are found in the path statement.
So PATH="/a:/b/1:etc..." the /a will be looked at first.

2-Dont forget to EXPORT your path! About once a week I work an extra 15min on a problem because I forgot to EXPORT the varaiable.

3-You may not have complete control of the path under Cygwin because MS Win may do some of its own hunting before the Cygwin path statement takes place. You will have to do some quick tests Smilie

I hope this helps you consider some options....
JZ
# 3  
Old 01-01-2009
Quote:
2-Dont forget to EXPORT your path! About once a week I work an extra 15min on a problem because I forgot to EXPORT the varaiable.
What does EXPORT do?

I have a script: newpath.sh

and in that is the line:

PATH="/cygdrive/d/dev/Builds/BuildOutputDir:.:"

and I run it using the source command:

. newpath.sh

and after that, when I enter "printf $PATH" I can see it has updated. Am I missing something?
# 4  
Old 01-01-2009
EXPORT allows changes to a variable to be global. If you have a shell opened and you change the path variable, then go to another shell window, the change will not show up. If you EXPORT it, it is like telling UNIX to notify all the programs that there is a new version of that variable.
# 5  
Old 01-01-2009
Thanks for that jwzumwalt, I really appreciate your help. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Php search path

Probably simple, but I don't see it. jack@veritron /u/email $ cat p3.php <?php require_once './lib/swift_required.php'; $x=get_include_path(); echo "$x \n"; set_include_path('./lib:./lib/classes:'.$x); $x=get_include_path(); echo "$x \n"; $transport =... (1 Reply)
Discussion started by: jgt
1 Replies

2. Programming

Gcc linker search path order

I have a build where I wish to link against and load a specific version of a library and a different version of the same library is installed on the system. I'm using a -L option to point to the version that I wish to link against but gcc still seems to choose the installed version. Is there a way... (4 Replies)
Discussion started by: Richard Johnson
4 Replies

3. UNIX for Dummies Questions & Answers

How to add to the search path - bin?

Hi, Now I have: /Users/okn/bin for my private shell scripts. How do I add /Users/okn/bin to my PATH? The PATH is right now: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin The .bash_profile doesn't state anything about a PATH (yet). I read about this: PATH=/bin:$PATH
 export PATH or... (1 Reply)
Discussion started by: OmarKN
1 Replies

4. Shell Programming and Scripting

Conduct a search or test -f over a path with spaces

I am organizing my music library on a NAS server. I want to print a list of all the directories that are missing the cover art (at least one or more jpeg file). I have successfully created a file with each line containing the path to each occurance of one or more .mp3 files. That path is also... (2 Replies)
Discussion started by: godfreydanials
2 Replies

5. Shell Programming and Scripting

How to select the shortest path in grep search?

Hi, How can I display only one shortest path (A/B/configure)? $ grep configure file.txt A/B/configure A/B/C/configure A/B/C/D/configure Thank you. (9 Replies)
Discussion started by: hce
9 Replies

6. Shell Programming and Scripting

How to find duplicate commands in the search path?

I wanted to see if there is any duplicate of a specific command in the command search path. The following code will list all copies of "openssl" in the command search path. find `printenv PATH | sed "s/:/ /g"` -maxdepth 1 -name openssl However, the above code would fail if the search path... (9 Replies)
Discussion started by: LessNux
9 Replies

7. Shell Programming and Scripting

grep - search order

Hi, I would like "grep" command to search ALL files in current directory in the order of their modified/created date. How can i do this? e.g., if 3 files contain the pattern i am searching for, i need the output of "grep" to be in the order such that old file search result should come first.... (6 Replies)
Discussion started by: prvnrk
6 Replies

8. UNIX for Dummies Questions & Answers

Adding default search path for CPP

Hi there, I have built myself a GCC (3.4.4) for PowerPC with a cross compilation toolchain running on a x86, together with glibc-2.3.4 and binutils-2.16. On the PowerPC there is a system runnign already (only console ofc, nothing "cosy", kernel-2.6.15). So my question is how to propperly... (1 Reply)
Discussion started by: boyanov
1 Replies

9. UNIX for Dummies Questions & Answers

home directory in search path

Is it unsafe to put your own home directory (a regular user) in your search path? I am writing useful shell scripts, but don't have the permissions to put them in /usr/bin. (Korn shell) thanks (2 Replies)
Discussion started by: jpprial
2 Replies
Login or Register to Ask a Question