Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Dear all,
I am installing different version of ns2 in my machine, in different directories under the Home folder. Now that I need to append the library path into bashrc, I am totally confused. I have little idea about it, and saw post about conflicting the environment path and system crash.
My library path is like: # LD_LIBRARY_PATH
OTCL_LIB=/home/shojaru/ns-allinone-2.28/otcl-1.9
NS2_LIB=/home/shojaru/ns-allinone-2.28/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/shojaru/ns-allinone-2.28/tcl8.4.5/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/shojaru/ns-allinone-2.28/bin:/home/shojaru/ns-allinone-2.28/tcl8.4.5/unix:/home/shojaru/ns-allinone-2.28/tk8.4.5/unix
NS=/home/shojaru/ns-allinone-2.28/ns-2.28/
NAM=/home/shojaru/ns-allinone-2.28/nam-1.11/
PATH=$PATH:$XGRAPH:$NS:$NAM
Now that I will add environment variable for another ns2, should I keep the above one and add another same block by only modifying the path to new ns2? Like: # LD_LIBRARY_PATH
OTCL_LIB=/home/shojaru/new/ns-allinone-2.29/otcl-1.9
NS2_LIB=/home/shojaru/new/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
And keep both the two blocks in the bashrc?
Or, I have to append them in the existing path? Would anyone care to elaborate a little bit on this? Please?
Thank you very much for your kind attention and response
I don't use NS2 but I think it depends on how you usually switch things. Try adding this to your ~/.bashrc:
Code:
set_NS2_VER() {
# Setting the default NS2 version
NS2_VER="2.29"
# Getting the version from a file (echo "2.28" > ~/.ns2_version)
[ -f ~/.ns2_version ] && NS2_VER=$(cat ~/.ns2_version)
case "$1" in
old|2.28) NS2_VER="2.28";;
new|2.29) NS2_VER="2.29";;
*) continue;;
esac
# The basename of your NS2 installs
NS2_BASE=/home/shojaru/ns-allinone
NS2_LIB=${NS2_BASE}-${NS2_VER}/lib
OTCL_LIB=${NS2_BASE}-${NS2_VER}/otcl-1.9
TCL_LIB=${NS2_BASE}-${NS2_VER}/tcl8.4.5/library
USR_LIB=/usr/lib
USR_LOCAL_LIB=/usr/local/lib
X11_LIB=/usr/X11R6/lib
XGRAPH=${NS2_BASE}-${NS2_VER}/bin:${NS2_BASE}-${NS2_VER}/tcl8.4.5/unix:${NS2_BASE}-${NS2_VER}/tk8.4.5/unix
NS=${NS2_BASE}-${NS2_VER}/ns-${NS2_VER}/
NAM=${NS2_BASE}-${NS2_VER}/nam-1.11/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
export PATH=$PATH:$XGRAPH:$NS:$NAM
}
set_NS2_VER old
This should give you access to a function called "set_NS2_VER" which, on parsing your .bashrc, will first set a default version, then glean it from ~/.ns2_version if it exists or else if the function is called with an argument like "new", "old", "2.28" or "2.29", then export what's needed. Note your NS2 installs should use same level dir names like "/home/shojaru/ns-allinone-2.28" and "/home/shojaru/ns-allinone-2.29".
Dear unSpawn,
I really cannot find the words to thank you, so much time u spent on writing the codes!!!
I wanted to ask another question. I run ns programs, by going to the specific directory and type in the terminal: ns example.tcl So now,if I edit the ~/.bashrc as above, would it be the same procedure as before? Like: shojaru@ubuntu:~/ns-allinone-2.28/ns-2.28$ ns example.tcl
shojaru@ubuntu:~/ns-allinone-2.29/ns-2.29$ ns example.tcl
or, I would have to change the procedure ?
Another question is, since I have already installed 2.29 on a different level directory, would it work if I just copy the whole directory into another location?
Thank you very much once again for your kind attention.
I run ns programs, by going to the specific directory and type in the terminal: ns example.tcl So now,if I edit the ~/.bashrc as above, would it be the same procedure as before?
Try 'set_NS2_VER old; cd ~/ns-allinone-2.28/ns-2.28; ns example.tcl' or 'set_NS2_VER 2.29; cd ~/ns-allinone-2.29/ns-2.29; ns example.tcl'
Quote:
Originally Posted by shojaru
since I have already installed 2.29 on a different level directory, would it work if I just copy the whole directory into another location?
I have no idea since I don't use NS2. You could always (make a backup and) try.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.