naa1810@dsacng1.UUCP (Bill Bereza) (07/24/87)
I recently experienced what I consider an inconsistency with my PATH variable. I had appended my bin directory path to the PATH variable. I had an existing shell script named "de" in my bin directory that simply executed the Unix date command. After I signed on the system in the C Shell, I did the following commands: cp de de2 cp de dee which de2 which dee de2 dee All worked properly. I then did: cd / de2 dee Much to my amazement, 'dee' did not work--I received "Command not found" from the system. I further experimented and found out that I could not execute a new shell script that I created in my bin directory from any directory path except when my cwd was my bin directory. I also noted that when I logged off and then back on, all my bin shell scripts would properly execute from any cwd. If anyone can explain to me what is going on with my PATH variable, I would greatly appreciate it. THANKS.
gwyn@brl-smoke.ARPA (Doug Gwyn ) (07/25/87)
In article <155@dsacng1.UUCP> naa1810@dsacng1.UUCP (Bill Bereza) writes: >I further experimented and found out that I could not execute a >new shell script that I created in my bin directory from any directory >path except when my cwd was my bin directory. Sounds like you corrupted your $PATH. The reason it worked when your cwd was your bin directory is that then the "." or "" in your $PATH found the command.
zhao@csd4.milw.wisc.edu (T.C. Zhao) (07/25/87)
Look up rehash on the csh man page : rehash Causes the internal hash table of the contents of the directories in the _p_a_t_h variable to be recomputed. This is needed if new commands are added to directories in the _p_a_t_h while you are logged in. This should only be necessary if you add commands to one of your own directories, or if a systems programmer changes the contents of one of the system directories. Hope this helps.
romain@pyrnj.uucp (Romain Kang) (07/26/87)
I'll probably be the 48nd person to answer, but... In article <155@dsacng1.UUCP> naa1810@dsacng1.UUCP (Bill Bereza) writes: | After I signed on the system in the C Shell ... ... | I further experimented and found out that I could not execute a | new shell script that I created in my bin directory from any directory | path except when my cwd was my bin directory. | I also noted that when I logged off and then back on, all my bin | shell scripts would properly execute from any cwd. This is because csh builds a hashed list of commands and their full path names when it starts up, based on the path (or PATH) variable. The current directory is not subject to this hash table, since it would be expensive to rebuild the table each time a user changed directories. (I cut my Unix teeth on a PDP-11/34 with RL01's, and I can still remember how the system paused when someone started a new csh -- but I digress...) A sensible compromise for a shell designer (living on small PDPs) would be to have the user explicitly rebuild the hash table when a command was added to the path. This is done with the csh "rehash" command. As they say, "It's a FEATURE!!!" The SVr2 sh and ksh have other hashing strategies that deal with changed paths, which in fact handle your case without any special rehash-style commands, while the old V7 sh tries to exec every possible pathname until it succeeds by brute force. (Imagine that on a slow CPU with slow disks...) -- Romain Kang {allegra,cmcl2,mirror,pyramid,rutgers}!pyrnj!romain ''!!!x89 dimaryP a fo edisni deppart m'I !pleH`` ``oNhwre eenraa sab dsab iegnt arppdei n aDP-P113/!4!!''
chris@mimsy.UUCP (Chris Torek) (07/26/87)
See `rehash' under `man csh'. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chris
mzw9022@ddmtg1.UUCP (grinder) (07/27/87)
In article <155@dsacng1.UUCP>, naa1810@dsacng1.UUCP (Bill Bereza) writes: > I recently experienced what I consider an inconsistency with > my PATH variable. I had appended my bin directory path to the PATH > > I further experimented and found out that I could not execute a > new shell script that I created in my bin directory from any directory > path except when my cwd was my bin directory. > > I also noted that when I logged off and then back on, all my bin > shell scripts would properly execute from any cwd. > When you log on, an internal hash table (which contains the contents of the directories in the PATH variable) is computed for you. If you add new commands you must recompute this internal hash table if you intend to execute these commands from a directory besides the one the new command is located in. One way to do this is to logoff and log back on, since your internal hash table is set up for you at the time of login. Another way to to this is to type in rehash. This will cause your internal hash table to be recomputed while you are in the C shell. -- Valerie Grinder (DEFENSE DEPOT MEMPHIS TENNESEE) 2163 Airways BLVD Memphis Tn 38114 901-775-6849 AV 683-6849 UUCP: {seismo!gould,cbatt!osu-eddie}!dsacg1!ddmtg1!vgrinder
woerz@iaoobelix.UUCP (07/28/87)
> /***** iaoobelix:comp.unix.ques / dsacng1!naa1810 / 7:41 pm Jul 24, 1987*/ > I recently experienced what I consider an inconsistency with > my PATH variable. I had appended my bin directory path to the PATH > variable. I had an existing shell script named "de" in my bin > directory that simply executed the Unix date command. > ... > [some command deleted] > ... > Much to my amazement, 'dee' did not work--I received "Command not found" > from the system. > > I further experimented and found out that I could not execute a > new shell script that I created in my bin directory from any directory > path except when my cwd was my bin directory. > > I also noted that when I logged off and then back on, all my bin > shell scripts would properly execute from any cwd. > > If anyone can explain to me what is going on with my PATH variable, > I would greatly appreciate it. THANKS. > /* ---------- */ You should have told, if you use the Borne shell, the cshell or the Korn shell. I don't know about the Korn shell and am not sure about your version of the Bourne shell, but the cshell (at least on vanilla 4.2BSD) hashes all commands it finds on invocation. So if you create a new script or new program, you have to say "rehash" to force cshell to rescan all directories in your path, before the shell recognizes the command from everywhere. Hope this helpes ------------------------------------------------------------------------------ Dieter Woerz Fraunhofer Institut fuer Arbeitswirtschaft und Organisation Abt. 453 Holzgartenstrasse 17 D-7000 Stuttgart 1 W-Germany BITNET: iaoobel.uucp!woerz@unido.bitnet UUCP: ...{seismo!unido, pyramid}!iaoobel!woerz
robertd@ncoast.UUCP (Rob DeMarco) (08/08/87)
In article <6175@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: >In article <155@dsacng1.UUCP> naa1810@dsacng1.UUCP (Bill Bereza) writes: >>I further experimented and found out that I could not execute a >>new shell script that I created in my bin directory from any directory >>path except when my cwd was my bin directory. > >Sounds like you corrupted your $PATH. The reason it worked >when your cwd was your bin directory is that then the "." or >"" in your $PATH found the command. This same thing happened to me. When I create a new shell script and put it in my bin directory. It wount execute except when I am IN the directory. This would remain in effect untill I logged off or called up csh again. I just excepted that and tried to live with it. I guest cshell (and shell too?) stores those files in memory so it doesn't have to keep physically searching for a command and waist time. Can some one offer help in why it really does this? [> Rd -- North Coast Computer Resources(ncoast) - 216-781-6201 (or 781-6202) UUCP:decvax!cwruecmp!ncoast!robertd Sysop: NEODG (login "sbbs")
tim@amdcad.AMD.COM (Tim Olson) (08/08/87)
In article <4092@ncoast.UUCP> robertd@ncoast.UUCP (Rob DeMarco) writes: +----- |>In article <6175@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: |>>In article <155@dsacng1.UUCP> naa1810@dsacng1.UUCP (Bill Bereza) writes: |>>>I further experimented and found out that I could not execute a |>>>new shell script that I created in my bin directory from any directory |>>>path except when my cwd was my bin directory. |>> |>>Sounds like you corrupted your $PATH. The reason it worked |>>when your cwd was your bin directory is that then the "." or |>>"" in your $PATH found the command. |> |> This same thing happened to me. When I create a new shell script and put it |>in my bin directory. It wount execute except when I am IN the directory. This |>would remain in effect untill I logged off or called up csh again. I just |>excepted that and tried to live with it. I guest cshell (and shell too?) |>stores those files in memory so it doesn't have to keep physically searching |>for a command and waist time. Can some one offer help in why it really does |>this? +----- Did you "rehash" after you installed the program in your bin directory? csh keeps a hash table of all executable programs it finds when it searches your $PATH, and won't find any new executables. You can force it to research your $PATH by typing "rehash". -- Tim Olson Advanced Micro Devices (tim@amdcad.amd.com)