LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 06-20-2007, 02:18 PM   #1
nexisrocks
LQ Newbie
 
Registered: Jun 2007
Posts: 7

Rep: Reputation: 0
Adding a Path to .bash_profile


I have an account on a group of servers called ace-net, and there is a program on there (in a very different folder) which I would like to add a path name for. However, I am unsure as the exact command(s) needed to put in the folder.

The path I want to add is /home/pyuet/usr/local/gromacs-3.3.1/bin/<program name>

I've googled it, but several sites say slight different things, so I'm confused.

Below is the only code located in .bash_profile at the moment.

if [ -f /usr/local/lib/bash_profile ]; then
. /usr/local/lib/bash_profile
fi

I appreciate any help that can be given!
 
Old 06-20-2007, 02:40 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
At the end of .bash_profile, add the following:
Code:
export PATH=$PATH:/home/pyuet/usr/local/gromacs-3.3.1/bin
If your $HOME is correctly set (and it probably is), you could put this instead:
Code:
export PATH=$PATH:$HOME/usr/local/gromacs-3.3.1/bin
From there, you can either source your .bash_profile to make the settings take effect (source .bash_profile or . .bash_profile), log out and log in again, or type the export statement on the command line to have it take effect for just the current shell.
 
Old 06-20-2007, 03:00 PM   #3
nexisrocks
LQ Newbie
 
Registered: Jun 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you!

However, when I tried to source it, I got the error message if: Expression Syntax.

I tried taking out the path command, and it did the same thing.

What is in there right now is:

if [ -f /usr/local/lib/bash_profile ]; then
....../usr/local/lib/bash_profile
fi

export PATH=$PATH:/home/pyuet/usr/local/gromacs-3.3.1/bin


(If you can see them, those little really light blue dots don't mean anything).

Thanks!

Last edited by nexisrocks; 06-20-2007 at 03:01 PM.
 
Old 06-20-2007, 03:44 PM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You should enclose code samples in a CODE block to preserve indentation when posting them. The if command syntax looks OK to me. Is bash or sh your default shell?

Code:
if [ -f /usr/local/lib/bash_profile ]; then
   .  /usr/local/lib/bash_profile
fi
Bash expects the system startup script to be located in /etc/profile. This location is not standard so it is sourced if it exists. Since you added spaces which look like little dots, I can't tell if the second line is
Code:
. /usr/local/lib/bash_profile
or /usr/local/lib/bash_profile
or ./usr/local/lib/bash_profile
The first will source the /usr/local/lib/bash_profile file.
The second will run /usr/local/lib/bash_profile in a subshell, so changes in that script won't be retained.
The third will run $HOME/usr/local/lib/bash_profile. See if this script exists.

Code:
export PATH=$PATH:/home/pyuet/usr/local/gromacs-3.3.1/bin
This line will add /home/pyuet/usr/local/gromacs-3.3.1/bin/ to your $PATH variable. This line looks correct if you are using the bash or sh shell.

If you are using another shell, then /home/pyuet/.profile may not be sourced when you login.
Look at the output of "grep pyuet /etc/passwd".
Code:
pyuet:x:1000:1001:The Great Mr Pyuet:/home/pyuet:/bin/bash
The last field will contain something like /bin/bash or /bin/sh or /bin/csh or /bin/tsh.
You can change your default shell with the "chsh" command. (see man chsh).
The possible shells are listed in /etc/shells:
example:
Code:
cat /etc/shells
/bin/ash
/bin/bash
/bin/bash1
/bin/csh
/bin/false
/bin/ksh
/bin/sh
/bin/tcsh
/bin/true
/bin/zsh
/usr/bin/csh
/usr/bin/ksh
/usr/bin/passwd
/usr/bin/bash
/usr/bin/rbash
/usr/bin/tcsh
/usr/bin/zsh
Don't select /bin/true or /bin/false of course. /usr/false is used for system user accounts to prevent logins on that account.

One other thing to note. Even if you are using the /bin/bash shell, it is only sourced when you login.

There is another way of doing the test in your ~/.profile script. You can use the test command:
Code:
From my ~/.profile:
test -z "$PROFILEREAD" && . /etc/profile

Your three lines could be instead:
test -f /usr/local/lib/bash_profile && . /usr/local/lib/bash_profile

Last edited by jschiwal; 06-20-2007 at 03:49 PM.
 
Old 06-20-2007, 07:54 PM   #5
nexisrocks
LQ Newbie
 
Registered: Jun 2007
Posts: 7

Original Poster
Rep: Reputation: 0
My default shell is tcsh.

Code:
if [ -f /usr/local/lib/bash_profile ]; then
     ./usr/local/lib/bash_profile
fi

export PATH=$PATH:/home/pyuet/usr/local/gromacs-3.3.1/bin
Is what it is supposed to be (so option number three).

How do I tell if a script exists? Do I use:

Code:
echo $HOME/usr/local/lib/bash_profile
If I run that, it returns /home/sfitzsim/usr/local/lib/bash_profile (which I assume means it does exist).

When I try to run "grep pyuet etc/passwd", it says grep can't open etc/passwd.

I still don't understand why it's returning an error on the 'if' - how do I fix it?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I put PATH in bash_profile or bashrc or both? nick623 Linux - General 14 03-31-2007 06:41 PM
Adding Java to my path in the .bash_profile file .... jmax24 Linux - General 5 04-20-2004 01:14 PM
kde3.2 $PATH and .bash_profile easywebdev Slackware 2 03-29-2004 04:42 PM
kshell in path & .bash_profile dmartinez Linux - Newbie 3 03-31-2003 10:15 PM
.bash_profile & path Syncrm Linux - General 11 01-30-2002 01:49 PM


All times are GMT -5. The time now is 01:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration