LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-08-2011, 01:24 PM   #1
dwf
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
Unhappy Problem disabling Linux directory path hashing.


Linux version
Linux ldalxxx 2.6.18-238.12.1.0.1.el5 #1 SMP Tue May 31 14:51:07 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

We have a lot of AIX/Solaris Unix boxes that use a lot of Korn shell environment setup and scripts.

The problem comes on this new Linux box with how the Path statement gets used and remembered.

On Unix, the path gets searched every time you execute something.

On Linux, it remembers where it found it last time and will reuse that, even if a newer version of the command is now earlier in the path.

hash -r will clear that, but I need to turn this feature off.

set +h Should do this.

Set +h works correctly if I am in Bash shell, but not in Korn Shell.


I really need a way to turn this "feature" off in our Korn shell Linux environments.
( I have also tried switch to Bash shell, turn it off, and switch to Korn to see if it was then off. It is back on in Korn shell).

Please let me know if there is any way to turn this off under a Korn shell.

Thanks


In Korn shell, set +h is "accepted" as a command, but it does not turn off directory "hashing".

These sessions need to remain in Korn shell, and manually resetting the hash with hash -r is not feasable. I need to turn it off in the profile and leave it off so that it will honor the path variable for every command.

Again, set +h works as expected IF I switch to Bash. Fails if I am in Korn.


Sample session log. . .
$ echo $SHELL
/bin/ksh
$ pwd
/export/home/cfsh_mgr
$ which test.ksh
~/testdir/test.ksh
$ echo $PATH
/export/home/cfsh_mgr/testdir:/export/home/cfsh_mgr:/usr/kerberos/bin:/usr/bin:/bin:/sbin:/usr/sbin:/fisc/sysman/bin:/fisc/uts/bin
$
$ cat test.ksh
echo IN THE HOME DIRECTORY!!!!!!!

$ cat ~/testdir/test.ksh
echo IN THE SUB DIRECTORY!!!!!!!


$ # it finds the correct test.ksh in the testdir. . .

$ test.ksh
IN THE SUB DIRECTORY!!!!!!!
$ rm ~/testdir/test.ksh
$
$ # Which show the only remaining version.
$ which test.ksh
~/test.ksh
$ # whence shows the now missing cached location.
$ whence test.ksh
/export/home/cfsh_mgr/testdir/test.ksh
$

$ # Notice, it still tries to go to the hashed sub dir version.
$ test.ksh
-ksh: test.ksh: not found [No such file or directory]
$

$ # it accepts the set +h but ignores it. Yes, I have tried this
$ # at the TOP of my session before any location lookups as well.
$ # if I were in Bash shell, the set +h works fine.
$ set +h
$ test.ksh
-ksh: test.ksh: not found [No such file or directory]
$
$ # hash -r works in Bash AND Korn to clear out the saved locations.

$ hash -r
$ test.ksh
IN THE HOME DIRECTORY!!!!!!!
$

Last edited by dwf; 11-08-2011 at 01:29 PM. Reason: add ending comments.
 
Old 11-08-2011, 03:17 PM   #2
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
I think +h stops the shell automatically adding tracked aliases but doesn't clear the tracked-alias table. Try doing hash -r when you do the set +h, or just do set +h right at the start....

Also:
Quote:
I have also tried switch to Bash shell, turn it off, and switch to Korn to see if it was then off. It is back on in Korn shell
bash and ksh don't talk to each other unless you put a fair amount of effort into setting up a custom environment that works that way. If you have one of those, debugging the communications failure is a separate problem.
 
0 members found this post helpful.
Old 11-09-2011, 12:38 PM   #3
dwf
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Sorry, Guess I was not clear on that.

set +h just does not turn off this "feature" when I am in Korn shell. Nothing seems to turn it off.

Korn shell accepts and completely ignores the set +h command completely.

Clearing history is not my problem. I just need to get it turned off and I will be happy.


Bash, set +h turns it off like it is documented. Korn, nope.

(I also tried a various permutations of set shopt and set -o hashall hoping they might turn it off, but no luck with those commands either).
 
Old 11-09-2011, 12:47 PM   #4
dwf
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Addendum. . .

I initially tried doing the set +h right after the .profile before any locations could be added. This sequence works for Bash, but not Korn.

My example above should have been longer to show that test as well.

Thanks for looking though. Any other suggestions are welcome.
 
Old 11-09-2011, 03:23 PM   #5
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
Code:
~$ ksh
$ echo $KSH_VERSION _
Version JM 93u 2011-02-08 _
$ set +h
$ PATH=~/sandbox:$PATH
$ echo echo bin > bin/foo
$ chmod +x bin/foo
$ foo
bin
$ echo echo sandbox > sandbox/foo
$ chmod +x sandbox/foo
$ foo
sandbox
$ chmod -x sandbox/foo
$ foo
bin
$ rm sandbox/foo
$ rm bin/foo
$ foo
ksh: foo: not found [No such file or directory]
$
Post your $KSH_VERSION.
 
1 members found this post helpful.
Old 11-10-2011, 08:25 AM   #6
dwf
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
jthill,
Thank you so much for checking your box. Now at least I know that it is specific to either my Linux or KSH version and not generic to all Linux.

My output below, and If anyone would like to check there own version, I have just the command pulled out at the very bottom so you can cut and just paste the whole set of commands to try it on your box.

My output
$ echo $KSH_VERSION
Version AJM 93t+ 2010-02-02
$ set +h
$ mkdir ~/sandbox
$ mkdir ~/bin
$ PATH=~/sandbox:~/bin:$PATH
$ echo PATH is $PATH
PATH is /export/home/cfsh_mgr/sandbox:/export/home/cfsh_mgr/bin:/usr/kerberos/bin:/usr/bin:/bin:/sbin:/usr/sbin:/fisc/sysman/bin:/fisc/uts/bin:.
$ echo echo bin > ~/bin/foo
$ chmod +x ~/bin/foo
$ echo You should see bin displayed
You should see bin displayed
$ foo
bin
$ echo echo sandbox > sandbox/foo
$ chmod +x sandbox/foo
$ echo You should see sandbox displayed
You should see sandbox displayed
$ foo
bin
$ chmod -x sandbox/foo
$ echo You should see bin displayed
You should see bin displayed
$ foo
bin
$ rm ~/sandbox/foo
$ rm ~/bin/foo
$ rmdir ~/sandbox
$ rmdir ~/bin
$ echo You should see that foo is not found
You should see that foo is not found
$ foo
-ksh: foo: not found [No such file or directory]


Here are just the commands you can paste to try
echo $KSH_VERSION
set +h
mkdir ~/sandbox
mkdir ~/bin
PATH=~/sandbox:~/bin:$PATH
echo PATH is $PATH
echo echo bin > ~/bin/foo
chmod +x ~/bin/foo
echo You should see bin displayed
foo
echo echo sandbox > sandbox/foo
chmod +x sandbox/foo
echo You should see sandbox displayed
foo
chmod -x sandbox/foo
echo You should see bin displayed
foo
rm ~/sandbox/foo
rm ~/bin/foo
rmdir ~/sandbox
rmdir ~/bin
echo You should see that foo is not found
foo


So thanks tjhill, now at least I have a place to start looking. I was beginning to think I needed a different command in KSH or it just would not function in KSH or something like that.

dwf
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Linux zip, excluding whole directory path SirLouen Linux - Software 1 09-12-2010 03:40 PM
Find a file path and directory path ak.lokesh Linux - Newbie 3 02-19-2009 12:37 PM
Hashing using Divison Problem ckoniecny Programming 2 11-03-2006 08:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration