LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 06-07-2012, 05:47 AM   #1
Narges
Member
 
Registered: Oct 2011
Posts: 32

Rep: Reputation: Disabled
Setting environmental variables when installing ns2 on fedora 15


Hi. I'm trying to install ns2.29.3 on fedora15.
Following the steps required, I have installed ns2 successfully.
I installed it in a folder in the following path:
home/naregs/ns2/ns-allinone2.29

I used sudo gedit ~/.bashrc to edit the variables in the /.bashrc file.
I saved the file after changes, and now when I type ns I get %.
so ns2 and nam are working. I have not validate it yet.

BUT the problem is now that I want to login as root, when I type

[narges@localhost ~]$ su
Password:
bash: ‎#: command not found...
bash: ‎#: command not found...
bash: ‎#: command not found...
[root@localhost narges]#


As you can see, I am able to login as root but before that I get the "bash" error. and I dont understand why.
I restarted the system but i get the same problem.
Its the 2nd time I install ns2. I am 100% sure that the path variables are correct. I've paste them here for you to see. I dindt have this error the last time.

# LD_LIBRARY_PATH‎
OTCL_LIB=/home/narges/ns2/ns-allinone-2.29/otcl-1.11‎
NS2_LIB=/home/narges/ns2/ns-allinone-2.29/lib‎
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

‎# TCL_LIBRARY‎
TCL_LIB=/home/narges/ns2/ns-allinone-2.29/tcl8.4.11/library‎
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

‎# PATH‎
XGRAPH=/home/narges/ns2/ns-allinone-2.29/bin:/home/narges/ns2/ns-allinone-‎‎2.29/tcl8.4.11/unix:/home/narges/ns2/ns-allinone-2.29/tk8.4.11/unix‎
NS=/home/narges/ns2/ns-allinone-2.29/ns-2.29/‎
NAM=/home/narges/ns2/ns-allinone-2.29/nam-1.11/‎
PATH=$PATH:$XGRAPH:$NS:$NAM‎

I searched the web but havent found a solution yet. What have I done wrong in the /.bashrc file that gave me this error?
before I make changes in there, I couldnt run ns2 unless I go the directory. but at least i didnt have any bash error. now I can run ns2 and nam. and I can login as root. but everytime I get the errors shown above.
Please help me. Thanks in advance.
 
Old 06-07-2012, 05:57 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,645

Rep: Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532
Quote:
Setting environmental variables when installing ns2
Not required. Just install the binary /binaries, that you use :

cd ns-allinone2.29/ns-2.29/ ; su ; make install
cd ../nam-1.11/ ; make install

The binary 'ns' is hard coded to known the location of its libraries.
And 'nam' is usually partly statically compiled :
An OK nam will work on a Linux OS with no tcl and no ns2 installed !

.
 
1 members found this post helpful.
Old 06-07-2012, 05:58 AM   #3
Narges
Member
 
Registered: Oct 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
BTW, the first time i entered the path variables in bashrc file and saved them. it gave me

export ‎'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB'not a valid identifier
bash: ‎#: command not found...
bash: ‎#: command not found...

errors, I changed the Makefile.in under /home/narges/ns2/ns-allinone-2.29/ns-2.29
as follows:
CC = gcc34
CPP = g++34

so i dont get export error as before. but i get the one i posted in porst#1.

Last edited by Narges; 06-07-2012 at 06:00 AM.
 
Old 06-07-2012, 06:12 AM   #4
Narges
Member
 
Registered: Oct 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
Thank you knudfl for your fast reply.

Quote:
Originally Posted by knudfl View Post
Not required. Just install the binary /binaries, that you use :

cd ns-allinone2.29/ns-2.29/ ; su ; make install
cd ../nam-1.11/ ; make install

.
you say not required to set the path. but without it I can not run ns2 as root from anywhere. right? I have to go to the directory and type ./ns.

and the installation is done completely successfully. so I think the problem is not in the installation. It has to do with bashrc file which I dont understand.
I agree that nam is a separate application. last time I couldnt run nam1.11 on fedora 15 and had to use nam 1.14. But on this machin on a same fedora 15 os I can use nam 1.11.
 
Old 06-07-2012, 06:16 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,645

Rep: Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532
# 3.

Not quite clear, why you want to log in as root. ( Never required.)

And : It it not recommended to use any ns2 commands as root.
May prevent you from using your ns-2.29 as unprivileged user.

.
 
Old 06-07-2012, 06:21 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,645

Rep: Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532
# 5.
Quote:
.. not required to set the path. but without it I can not run ns2 as root from anywhere.
"ns2" is not to be used as root.



Quote:
I have to go to the directory and type ./ns.
No. # 'make install' will copy 'ns' to /usr/local/bin/ .
Thus 'ns' is in a system path, and can executed from any location.

.
 
Old 06-07-2012, 06:34 AM   #7
Narges
Member
 
Registered: Oct 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
# 5.

"ns2" is not to be used as root.

.
when I'm not logged in as a root (as a normal user), and I go to the

[narges@localhost tcl]$ cd /home/narges/ns2/ns-allinone-2.29/ns-2.29/tcl/ex
[narges@localhost ex]$ ./ns wireless.tcl
bash: ./ns: No such file or directory

But If I type
[narges@localhost ex]$ su
Password:
bash: ‎#: command not found...
bash: ‎#: command not found...
bash: ‎#: command not found...
[root@localhost ex]# ns wireless.tcl
i get results.

Thats why I have to be root to be able to run.
 
Old 06-07-2012, 06:55 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,645

Rep: Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532
Quote:
[narges@localhost tcl]$ cd /home/narges/ns2/ns-allinone-2.29/ns-2.29/tcl/ex
[narges@localhost ex]$ ./ns wireless.tcl
bash: ./ns: No such file or directory
No, of course not. The period ( . ) in "./ns"
means a file in the current directory.
And there is no 'ns' in ns-2.29/tcl/ex/

..
 
Old 06-07-2012, 07:12 AM   #9
Narges
Member
 
Registered: Oct 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
No, of course not. The period ( . ) in "./ns"
means a file in the current directory.
And there is no 'ns' in ns-2.29/tcl/ex/

..
Here is the result without "."

[narges@localhost ~]$ cd /home/narges/ns2/ns-allinone-2.29/ns-2.29/tcl/ex
[narges@localhost ex]$ ns wireless.tcl
bash: ns: command not found...
Similar command is: 'nc'

Quote:
Originally Posted by knudfl View Post
No. # 'make install' will copy 'ns' to /usr/local/bin/ .
Thus 'ns' is in a system path, and can executed from any location.

..
So, I used make install under ns-allinone-2.29:

[narges@localhost ex]$ cd /home/narges/ns2/ns-allinone-2.29/
[narges@localhost ns-allinone-2.29]$ make install
make: Nothing to be done for `install'.
 
Old 06-07-2012, 07:57 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,645

Rep: Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532
Please see post # 2 :

cd ns-allinone-2.29/ns-2.29
su
make install && exit

( That's what root is for : Administrative tasks.
E.g. installing files to a location outside /home/<user-name> ).

.

Last edited by knudfl; 06-07-2012 at 07:58 AM.
 
Old 06-08-2012, 09:18 AM   #11
Narges
Member
 
Registered: Oct 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Please see post # 2 :

cd ns-allinone-2.29/ns-2.29
su
make install && exit

( That's what root is for : Administrative tasks.
E.g. installing files to a location outside /home/<user-name> ).

.
I did as you said above(make install under/ns2.29 and nam-1.11), now wherever I type #ns as a normal user, I get %.
I REMOVED the paths I entered in ./bashrc file, now when I type #su and I enter the password, I am logged in as root with NO bash: ‎#: command not found... error.

The problem now is when I want to run a tcl file under /tcl/ex I get the following error:

[narges@localhost ~]$ cd /home/narges/ns2/ns-allinone-2.29/ns-2.29/tcl/ex
[narges@localhost ex]$ ns simple.tcl
couldn't open "out.tr": permission denied
while executing
"open out.tr w"
invoked from within
"set f [open out.tr w]"
(file "simple.tcl" line 13)

(of course when I type the command as root I get results, but as u said I shouldnt use ns commands as root).
I think working with ns2, everytime you solve a problem you'll face a new one. so annoying.
Thank you so much for helping me.
 
Old 06-08-2012, 10:18 AM   #12
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,645

Rep: Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532
# 11.
Quote:
couldn't open "out.tr": permission denied
That's the reason why root shouldn't be used in /home/narges/.
The permissions will change, so only root has access.
Solution : su ; chown -R narges:narges ns/ns-allinone-2.29/*
chown -R narges:narges ns/ns-allinone-2.29/*/*
chown -R narges:narges ns/ns-allinone-2.29/*/*/*
chown -R narges:narges ns/ns-allinone-2.29/*/*/*/* && exit


Quote:
now when I type #su and I enter the password,
I am logged in as root with NO bash: ‎#: command not found... error.
No, you are not logged in as root, when you open a terminal.
It's just a terminal, that will accept administrative commands.

Don't know, why bash can't be used by root.
May be you added something to /root/.bashrc , when working as root.
Please have a look, and delete alien entries, if any.

.
 
1 members found this post helpful.
Old 09-05-2012, 01:55 AM   #13
Narges
Member
 
Registered: Oct 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
Hi again.
Regarding your post #12, I applied and changed the permission on my ns2.
But I have installed another ns2 in a different linux in VmWare earlier and I had used root to install ns2 and NIST mobile wimax module.
So now that I want to change the permission for ns2 folder, although I apply"chown" command the way you mentioned in post#12, It is not effective on this ns2.

ns2 is installed in /home/narges/ns-allinone-2.29
[narges@localhost ~]$ su
[root@localhost narges]# chown -R narges:narges /home/narges/ns-allinone-2.29/*
[root@localhost narges]# chown -R narges:narges /home/narges/ns-allinone-2.29/*/*
[root@localhost narges]# chown -R narges:narges /home/narges/ns-allinone-2.29/*/*/*
[root@localhost narges]# chown -R narges:narges /home/narges/ns-allinone-2.29/*/*/*/*
[root@localhost narges]# exit
exit
[narges@localhost ~]$ ns
bash: ns: command not found...
Similar command is: 'nc'

why is that so? I have installed NIST wimax and mobility on ns2 after solving lots of errors and really dont want to reinstall the ns2 again.
Is there anyway to solve it?
Thank you.
 
Old 09-05-2012, 02:11 AM   #14
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,645

Rep: Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532Reputation: 2532
# 13

This will show the files, that are still owned by root :

cd /home/narges/ns-allinone-2.29/
ls -Rl | grep root
( -Rl : upper case R. l is a lower case L ).

If you can't see which directory to files belong to, please try
ls -Rl | grep -B 20 root
.... where 20 is an example : Will show 20 lines above a hit.

When you have found the "owned by root files" cd <location>/
and : # chown narges:narges *

.

Last edited by knudfl; 09-05-2012 at 02:14 AM.
 
Old 09-05-2012, 03:16 AM   #15
Narges
Member
 
Registered: Oct 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
I get nothing when I enter the 2commands.
[narges@localhost ns-allinone-2.29]$ ls -Rl | grep root
[narges@localhost ns-allinone-2.29]$ ls -Rl | grep -B 20 root

nothing seemes to be owned by root.
but how come the permission is not changed on ns2 folder? I dont understand it
 
  


Reply

Tags
bashrc, ns2, path


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
Sun Grid Engine: setting environmental variables coenvh Linux - General 0 03-19-2010 05:14 AM
setting environmental variables permanently geetha_sg Slackware 6 08-10-2008 05:14 PM
Setting environment variables for NS2 installation over enterprize linux inamullah Linux - Enterprise 0 07-18-2008 01:01 AM
Setting environmental variables Ninju Linux - Newbie 3 09-25-2007 04:29 PM
Setting environmental variables in mandrake inprogress Linux - Newbie 4 06-07-2003 08:03 AM


All times are GMT -5. The time now is 09:48 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