Newbie PATH problem

General support questions including new installations

Newbie PATH problem

Postby mcharend » 2007/05/15 22:07:57

Hey All,

I am running CentOs 4.3 and am trying to run an application called Molaris. To run the the app, I am supposed to enter csh and issue the following two commands . . .

setenv MOLARIS_PATH "/home/mcharend/molaris"
setenv PATH "$MOLARIS_PATH/bin:$PATH"

While this does work, I would like to some how get this environment variable established on login. I have tried to sneak it in to my profile, but it just doesn't "take." What is the best way to make this happen? Any guidance would be appreciated as I obviously don't have a clue to how this script actually works. My login file is as installed . . .

GNU nano 1.2.4 File: profile

# /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


# 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
unset pathmunge
mcharend
 
Posts: 2
Joined: 2007/05/15 21:56:31

Newbie PATH problem

Postby pjwelsh » 2007/05/16 12:43:06

Many ways to get the "right"...more or less (that is more right or less right...). My fav is to use the /etc/profile.d/ framework for any of your custom stuff (on a global basis). So, as root, create a file in /etc/profile.d with a name you want with .sh extention (eg "my_custom_env.sh"). Then add:

export MOLARIS_PATH="/home/mcharend/molaris"
export PATH="$MOLARIS_PATH/bin:$PATH"

and anything else you want. The .sh will affect bash/ksh/sh shells. You can do the same kinda thing for csh by creating a similar named file (like "my_custom_env.csh"), but with csh syntax like you had at first.

Make sure the new files have execute perms.
pjwelsh
 
Posts: 2555
Joined: 2007/01/07 02:18:02
Location: Central IL USA

Re: Newbie PATH problem

Postby mcharend » 2007/05/16 20:13:55

This fix worked great. Also had the opportunity to learn about the chmod command. Thanks!!!
mcharend
 
Posts: 2
Joined: 2007/05/15 21:56:31


Return to CentOS 4 - General Support

Who is online

Users browsing this forum: No registered users and 1 guest