Can't add directory to path correctly

Hello everyone I am a newcomer to UNIX and I have hit a snag in something that would probably take experienced people about 30 seconds. Long story short I am trying to add a directory to my PATH and it is getting added but not working. I mean, the object of adding it to the path is so I can access it anywhere in my terminal right?

I am also confused about delimiters needed in tschrc. Do I need colons or not?

I used the command:

echo ' set PATH = ($PATH /usr/local/bin:/c4251/bin:)' >> ~/.cshrc

this added the directory permanently to the end of my path but i cannot access it from my home directory so what good is it?

I echoed my path and this is what I saw:

/usr/class/sce/bin:/usr/local/bin:/usr/local/matlab/bin:/usr/local/maple/bin:/usr/bin:/bin:.:/usr/lib64/qt-3.3/bin:/usr/NX/bin:/usr/class/sce/bin:/usr/local/bin:/usr/local/matlab/bin:/usr/local/maple/bin:/usr/bin:/bin:.:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin :/usr/local/bin:/c4251/bin

I added in colons because it appeared the other entries had them. Does this not work because there is a space in between the last entries? If this is the problem how to I correct this? Any help would be greatly appreciated. I am a beginner in UNIX!

Do you want to extend the PATH for yourself or everyone on the system?

Did you 'export' your newly set path?

I am no user of "tcsh" (and i actually suggest you switch to some standard shell - ksh or bash), but this can't be right:

All shells work similar in a certain respect: variables are not used like in high-level languages but are simply expanded into the text they contain and then the resulting line is interpreted. For instance:

command="ls"
options="-l"
$command $options

The syntax here is ksh, but it works the same: in the last line first "$command" is replaced with the content of the variable "command", then "$options" with the content of "options". The resulting line "ls -l" is then executed.

Your command adds a new line at the end of the file "~/.cshrc". The line is:

set PATH = ($PATH /usr/local/bin:/c4251/bin:)

Now suppose "PATH" contains, say "abc" and think what will happen upon execution - it will result in a variable which contains a space character, because your line just says that. In fact your variable contains this space character:

To answer your question regarding colons: yes, you need them. In fact you need them instead of spaces, because space chars will break the functionality of the PATH variable. You need them between the paths, but not at the end or the beginning. Your statement should therefore probably be:

echo 'set PATH = ($PATH:/usr/local/bin:/c4251/bin)' >> ~/.cshrc

Notice the missing space char and the different placement of the colons.

There are also some other issues with your PATH:

Notice that "/usr/local/bin", "/bin" and some other paths exist several times. This should be corrected. I suggest instead of just adding lines to "~/.cshrc" you should change it with an editor. You probably have several lines in it which add to the PATH variable. Edit these and remove duplicates.

Another thing is including "." in the PATH. This is not a functionality but a security issue. Still it is often done out of laziness. I suggest you do NOT rely on it, because in the long run the drawbacks outweigh the gains.

I hope this helps.

bakunin