LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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
  Search this Thread
Old 11-19-2009, 05:33 PM   #1
ggyyree
Member
 
Registered: Sep 2009
Location: London
Posts: 52

Rep: Reputation: 15
Question How to add an environment variable to the PATH?


I use Opensuse 11, and I build some C++ target under,

Code:
/opt/MyTools/bin
There are several programs under /opt/MyTools/bin I want to use directly from Bash (I don't want to type the full path but just the name of the program anywhere from Bash). I try to set the environment variable for the $PATH in .bashrc and .profile below,

Code:
export $PATH=$PATH:/opt/MyTools/bin
Then I source both .bashrc and .profile and echo the $PATH.

Code:
# source .bashrc
# source .profile
# echo $PATH
It seems the $PATH has been changed correctly; however, from the bash it can't find the program...I even try to create a .bash_profile but it doesn't work as well.
Code:
bash: ./displayGeometry: No such file or directory
Any suggestion would be appreciate. Thanks.
 
Old 11-19-2009, 06:39 PM   #2
sarum1990
Member
 
Registered: Dec 2008
Distribution: Gentoo, Debian
Posts: 31

Rep: Reputation: 21
I'm not sure, but I think you actually want:

Code:
export PATH=$PATH:/opt/MyTools/bin
(without the $ before the first path)

Also you should be able to just run
Code:
displayGeometry
instead of
Code:
./displayGeometry
Hope this helps

Last edited by sarum1990; 11-19-2009 at 06:40 PM. Reason: formatting
 
Old 11-19-2009, 06:42 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927
Quote:
Originally Posted by ggyyree View Post
I use Opensuse 11, and I build some C++ target under,

Code:
/opt/MyTools/bin
There are several programs under /opt/MyTools/bin I want to use directly from Bash (I don't want to type the full path but just the name of the program anywhere from Bash). I try to set the environment variable for the $PATH in .bashrc and .profile below,


Quote:
Originally Posted by ggyyree View Post
Code:
export $PATH=$PATH:/opt/MyTools/bin
Then I source both .bashrc and .profile and echo the $PATH.
Did that export statement actually work?!
It *should* say:
Code:
export PATH=$PATH:/opt/MyTools/bin

Code:
# source .bashrc
# source .profile
# echo $PATH
It seems the $PATH has been changed correctly; however, from the bash it can't find the program...I even try to create a .bash_profile but it doesn't work as well.
Code:
bash: ./displayGeometry: No such file or directory
Any suggestion would be appreciate. Thanks.[/QUOTE]

If it's not in the current working directory, a ./ won't
work. And what is your actual interactive shell?


Cheers,
Tink
 
Old 11-19-2009, 06:43 PM   #4
seaking1
LQ Newbie
 
Registered: Jan 2009
Posts: 21

Rep: Reputation: 16
Your syntax says you typed
<code>./displayGeometry</code>

Unless you are in the directory with the program, that will not work.
Having added the path to your $PATH you should be able to type
<code>displayGeometry</code>
from anywhere on your system.

The './' in front of your command is basically a shortcut absolute path telling bash to look for the program in you current working directory (.).
 
Old 11-20-2009, 12:49 PM   #5
ggyyree
Member
 
Registered: Sep 2009
Location: London
Posts: 52

Original Poster
Rep: Reputation: 15
Lightbulb

Quote:
Originally Posted by sarum1990 View Post
I'm not sure, but I think you actually want:

Code:
export PATH=$PATH:/opt/MyTools/bin
(without the $ before the first path)

Also you should be able to just run
Code:
displayGeometry
instead of
Code:
./displayGeometry
Hope this helps

Sorry about my typo. Yes, it should be export PATH=$PATH:/opt/MyTools/bin.

Thanks a lot, displayGeometry works without ./ as seaking1 explained as well. Thank you for all of you.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
PATH environment variable moonz Red Hat 3 09-08-2005 04:10 PM
changing path environment variable iNET_boss Linux - Newbie 2 07-27-2005 04:35 PM
Modifying the PATH environment variable brunnopessoa Linux - Newbie 11 11-03-2004 10:23 PM
which path do the environment variable files reside in ycli00 Linux - General 1 03-03-2004 01:57 AM
how do I edit the $PATH environment variable in RH7.3 needamiracle Linux - Software 3 07-02-2002 09:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration