LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting environmental variables when installing ns2 on fedora 15 (https://www.linuxquestions.org/questions/linux-newbie-8/setting-environmental-variables-when-installing-ns2-on-fedora-15-a-949000/)

Narges 06-07-2012 05:47 AM

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.

knudfl 06-07-2012 05:57 AM

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 !

.

Narges 06-07-2012 05:58 AM

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.

Narges 06-07-2012 06:12 AM

Thank you knudfl for your fast reply.

Quote:

Originally Posted by knudfl (Post 4697742)
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.

knudfl 06-07-2012 06:16 AM

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

.

knudfl 06-07-2012 06:21 AM

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

.

Narges 06-07-2012 06:34 AM

Quote:

Originally Posted by knudfl (Post 4697755)
# 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.

knudfl 06-07-2012 06:55 AM

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/

..

Narges 06-07-2012 07:12 AM

Quote:

Originally Posted by knudfl (Post 4697783)
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 (Post 4697783)
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'.

knudfl 06-07-2012 07:57 AM

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> ).

.

Narges 06-08-2012 09:18 AM

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.

knudfl 06-08-2012 10:18 AM

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

.

Narges 09-05-2012 01:55 AM

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.

knudfl 09-05-2012 02:11 AM

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

.

Narges 09-05-2012 03:16 AM

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


All times are GMT -5. The time now is 02:05 AM.