Thread: $path
View Single Post
  #4 (permalink)  
Old 14-Aug-2004, 20:35
rake
Guest
 
Posts: n/a
Default


What you have looks fine.

But I have noticed the same problem with multiple entries in $PATH. It seems that at after a reboot and logging in, that /etc/profile and $HOME/.profile are both getting run twice. Anyone else seeing this problem or know what might be causing it?

I fixed the double entry problem by borrowing a function from my old Red Hat install called "pathmunge". I put the following in a file (/local/etc/pathmunge).

###################
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|$1($|" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

shopath () {
echo -e ${PATH//:/"\n"}
}

export pathmunge shopath
######################

Then, within your /etc/profile.local, you could do:

. /local/etc/pathmunge
pathmunge /usr/local/nessus/bin after
pathmunge /usr/local/nessus/sbin after

which will add /usr/local/nessus/bin to your $PATH, unless it is already there.
The "after" puts it at the end. Leave off the "after" to put the new path at the beginning of $PATH.

The "shopath" function is just a convenience to print out $PATH one element per line. Just run the command "shopath" from a shell. (after running the command ". /local/etc/pathmunge" to load the file with the function defs.