Page 1 of 1
change path permanently
Posted: Sun Oct 03, 2004 1:13 pm
by Red Squirrel
I have a folder in /data/scripts that I want to set as my path.
I tried export path=$path:/data/scripts
The first time it worked, so figured perfect, so I added it to my rc.local file... but suddently the command itself stopped working. I rebooted the server, and it did not take affect, so I typed it manually, it did not take affect.
So is there a different way of doing it that's consistant?
Archived topic from Anythingforums, old topic ID:1116, old post ID:14046
change path permanently
Posted: Fri Oct 08, 2004 1:50 am
by megaspaz
use pathmunge in /etc/profile
here's an example of setting java's directory and intel's c++ compiler into the path using pathmunge.
Code: Select all
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)"; then
if [ "$2" = "after" ]; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# Path manipulation
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
pathmunge /usr/X11R6/bin after
JAVA_HOME=/usr/java/j2sdk1.4.2_02
pathmunge $JAVA_HOME/bin after
export JAVA_HOME
ICC_HOME=/usr/local/intel/compiler70/ia32
pathmunge $ICC_HOME/bin after
export ICC_HOME
KOMODO_HOME=/usr/local/Komodo-2.5
pathmunge $KOMODO_HOME after
export KOMODO_HOME
unset pathmunge
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
. $i
fi
done
unset i
Archived topic from Anythingforums, old topic ID:1116, old post ID:14541
change path permanently
Posted: Fri Oct 08, 2004 1:34 pm
by Red Squirrel
holy crap did not know it would be that complicated.
mind explaining that line by line or pointing me to a resource, I don't even know where I would put the actual path in that code...
Archived topic from Anythingforums, old topic ID:1116, old post ID:14578
change path permanently
Posted: Sat Oct 09, 2004 3:36 am
by megaspaz
all you really need is the pathmunge line. if you want to create an environment variable use this block of code.
Code: Select all
JAVA_HOME=/usr/java/j2sdk1.4.2_02
pathmunge $JAVA_HOME/bin after
export JAVA_HOME
the first line creates an environment variable called JAVA_HOME and sets its value to /usr/java/j2sdk1.4.2_02
the second line, puts the path at the end of your existing list of paths.
the third line exports the variable for use.
i think you can just get away with the second line.
ex. --> pathmunge /data/scripts after
put that line after root's path is set (the if/fi block starting with the comment "Path Manipulation") but before the "unset pathmunge" line.
Archived topic from Anythingforums, old topic ID:1116, old post ID:14626
change path permanently
Posted: Sat Oct 09, 2004 7:33 pm
by Red Squirrel
Finally got it working, thanks!
Archived topic from Anythingforums, old topic ID:1116, old post ID:14636