LinuxQuestions.org
Visit Jeremy's Blog.
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 12-29-2006, 03:59 PM   #1
myrto
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Rep: Reputation: 15
adding variables to the PATH


I have recently downloaded ns-2 network simulator and I am trying to add ns' directory to the environment variable PATH. The path of the directory that contains a link to the ns's executable file is:
/home/Myrto/ns-allinone-2.30/bin
and the path of the actual executable file is:
/home/Myrto/ns-allinone-2.30/ns-2.30/ns

I have tried:
export ns=/home/Myrto/ns-allinone-2.30/bin
export $PATH=$PATH:$ns

along with just about anything else that I could think of but I always get the message 'not a valid identifier'.
If anyone could offer any suggestions I would be very grateful! Thanks.
 
Old 12-29-2006, 04:09 PM   #2
dombrowsky
Member
 
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235

Rep: Reputation: 31
look at that code one more time.... carefully.

you're doing this:
Code:
A=foo
$A=$A:bar
which evaluates to
Code:
A=foo
foo=foo:bar
which may or may not work, and is certainly not what you intended.
 
Old 12-29-2006, 04:26 PM   #3
voger
Member
 
Registered: Oct 2005
Distribution: Arch
Posts: 68

Rep: Reputation: 15
Code:
export PATH=$PATH:/home/Myrto/ns-allinone-2.30/bin
 
Old 12-30-2006, 01:53 AM   #4
myrto
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Original Poster
Rep: Reputation: 15
Thank you very much!
 
Old 12-31-2006, 12:36 AM   #5
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
The code voger gave you is correct. But you have to run that command each time you boot up your computer or login. Linux reads the default PATH statement from your profile or login script.

If you use the bash shell. In your home directory, you will have either profile or bash_profile. There will be something like
this in either file:

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:."

The colons separate the folders. The period at the end of the PATH varible means you can run a program from the current directory. As an
example, put the directory you want betwwen
the coloons. Like this for example

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/home/Myrto/ns-allinone-2.30/bin:."

Save and exit. To take effect, you must log
out and then log in. Or you can type
source profile or source bash_profile. The
source command will re-read the file. Now you
can run the program anywhere from your home
directory.

Hope this helps you out.
 
Old 01-21-2007, 11:31 PM   #6
hottdogg
Member
 
Registered: Aug 2004
Distribution: opensuse ,debian
Posts: 207

Rep: Reputation: 30
How to add variable permanently (so I don't have to export everytime I login) without altering the current path variables if my .bash_profile and.bashrc are blank?
for example i want to add this: /usr/local/arm/bin

Currently I can only see the path variables using echo $PATH

tnx.
 
Old 01-22-2007, 02:06 AM   #7
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
If your .bash_profile or .bashrc is blank, then you need
to edit the /etc/profile as root.

Open the /etc/profile with any text editor.

Search for something like this, yours may vary.

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:."

Each directory is separated by colons. Add the directory you want, in your case /usr/local/arm/bin within the colons. An example

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/local/arm/bin:."

Save and exit. To take effect, you need to logout and then login.


Good luck
 
Old 01-22-2007, 03:23 PM   #8
dombrowsky
Member
 
Registered: Dec 2005
Location: New York
Distribution: Debian/GNU
Posts: 235

Rep: Reputation: 31
Quote:
If your .bash_profile or .bashrc is blank, then you need
to edit the /etc/profile as root.
You shouldn't be doing this if you don't understand exactly what the files are and where they insert themselves in login/boot scripts.

For the details on what bash(1) runs on startup/login, see the INVOCATION section of the manual (type 'man bash'). In short, ~/.bash_profile is only run on login.

In almost all setups I've seen, there is a default .bash_profile that contains something like:
Code:
# include .bashrc if it exists

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi
This means, all you have to do is CREATE the ~/.bashrc file and it will automagically be sourced in the login shell.

-dave
 
Old 01-23-2007, 09:34 PM   #9
hottdogg
Member
 
Registered: Aug 2004
Distribution: opensuse ,debian
Posts: 207

Rep: Reputation: 30
hmm..getting more confused
oh ..1 more thing I can also look path variables using 'set'.
Anyway, I'm newbie about this bash thing.
I've read the INVOCATION part in bash man.
actually, i want to make /usr/local/arm/bin behave like this :
user (either from gui shell, login shell,any shell) can run
$arm-linux-gcc
while root must use
#/usr/local/arm/bin/arm-linux-gcc

this is a similiar behaviour like
root can run
#ifconfig
while user must use
$/sbin/ifconfig

you know what I mean?

Tnx.

--edit--
fyi, i use slackware 11 upgraded from 10.2.If that matter....

Last edited by hottdogg; 01-23-2007 at 09:35 PM.
 
  


Reply

Tags
error, syntax


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
installing older version of gcc and and adding path variables jaind Linux - Desktop 3 11-26-2006 07:18 AM
Need help w/ a few PATH and Environment variables DaFrEQ SUSE / openSUSE 3 06-10-2006 05:12 PM
Extra path variables? mjm461 Linux - General 1 09-15-2005 03:21 PM
Setting PATH and other variables durrantj Ubuntu 2 08-25-2005 08:44 PM
adding $PATH variables karupt Linux - Newbie 5 03-07-2004 07:27 PM


All times are GMT -5. The time now is 04:26 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration