I was wondering if someone could tell me how to set up an alias for a data analysis tool.
With Python,
typing python from terminal gives me python 2.7*
typing python3 from terminal gives me python 3.*
I have a data analysis tool that I learned to compile from the source, by editing my .bashrc
typing root form terminal gives me root-5.35-*
now they came up with a new version ROOT 6.02*,
ROOT 6.02 does not sit well with my older codes because of the differences in declaration of pointers.
a.that() needs to be all swapped to
a->that(), and I’m sure that there are some other things that I am yet to notice. In short scripts that I’ve already written which plays nice with ROOT 5.34 does NOT play nice with ROOT 6.02
I wish to set things up such that
if I type
root, it brings up ROOT 5.*
and root6 giving me ROOT6.*
The order is important because the binary/executable is being search in your path from left to right so if when you type your program and the system finds it in ~/bin then that is used if not then the search continues.
The caveat of using ~/.bashrc for your aliases is it assumes you are using bash as your log-in shell.
For system wide aliases you can put it in (non-existent)
/etc/bash.bahsrc.local
Again it assumes bash as the log in shell for all users.
Please do show us things. E.g. do not tell a story about ROOT being in ~/ROOT, but post what happens when you do
ls -l ~/ROOT
Copy/paste computer text complete (that is prompt, command, output and next prompt) in one sweep between CODE tags in your post. You get the CODE tags by clicking on the # button in the tool bar of the post editor.
I never would put such programs dircetly in my home directory. You better organise things in using separte directories for separate things. In this case there is already a directory bin in your home directory. So better move ROOT and ROOT6 there: ~/bin/ROOT and ~/bin/ROOT6. This has the advantage that ~/bin is in your PATH environment variable and will thus be found if you simply call it as
ROOT
from whichever working directory you happen to be.
Check if you, the owner, can excute it. In other words the x-bit for owner must be set. When not do
cd ~/bin
chmod u+x ROOT ROOT6
Now it eems that you do not want to call it as
ROOT
ROOT6
but as
root
root6
There are three (3) solutions here:
a) change the name of the files:
cd ~/bin
mv ROOT root
mv ROOT6 root6
b) when you do not like that, make hard links:
cd ~/bin
ln ROOT root
ln ROOT6 root6
or create aliases in ~…/alias by using the editor you love to create (or edit when it is already there) ~/.alias and ad the lines:
From your posts I understood that you have executable files ~/ROOT and ~/ROOT6.
The above shows that ~/ROOT is a directory containing the unpacked tarball.
Thus we have to start all over in understanding what you mean.
Not much time at the moment and it looks as I have to formulate some questions very thouroughfully to avoid further misunderstandings.
You do not show what is in there, thus how can I know?
May I assume that the above is the same as is in thisroot.sh
What happens now is that the PATH and LD_LIBRARY_PATH are extended at the beginning again. Thus when you switch several times in a session, those two will grow and grow!
The following alias statements could help:
alias root="ROOTSYS=$HOME/ROOT PATH=$ROOTSYS/bin:$PATH_LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH root"
alias root6="ROOTSYS=$HOME/ROOT6 PATH=$ROOTSYS/bin:$PATH_LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH root"
To begin with, I had to repair your CODE tags. When you click on the # button you get correct ones.
Second, it is not clear what you changed in your .bashrc. Post completely the before and after. Else nobody can guess what you added, changed, removed exactly.
Third, if it works what you do can you find out yourself: test it.
Fourth, I am unbable to decide what names within the ROOT6 tree must be changed. Remember that you set (and exported) a variable ROOTSYS. You now set ROOTSYS6, but I have no idea if the product uses SYSROOT anywhere. And when it does, it will point to the wrong product root. Same for the PATH variables. If you run a ROOT program which starts another ROOT program in a way that depends on PATH, then a ROOT6 version will be started when that specification comes first. Same (and mayby worse) for dynamic loaded libraries.
I gave a suggestion. You are not obliged to follow it, but then please say so. Then I can spend my free time for other problems here in the forums.
And my idea is that you do not realy understand what:
environment variables are;
how the PATH and LD_LIBRARY_PATH environment variables are used and thus should be managed.
You’re correct, my understanding on environmental variables/settings are limited.
My .bashrc did not have anything to do with ROOT, I wrote the following in myself after searching on google. I will get back to you after testing. I am still compiling. Thank you
-SJL
alias root="ROOTSYS=$HOME/ROOT PATH=$ROOTSYS/bin:$PATH_LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH root"
alias root6="ROOTSYS=$HOME/ROOT6 PATH=$ROOTSYS/bin:$PATH_LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH root"
unfortunately did not work,
ROOT5 worked fine,
ROOT6 turned on ROOT5 and crash after freeze.
So far, for running macros and executables, everything seems to work well.
I am unsure now on what you did. Did you reverse all the name changes you did inside ROOT6?
My advice to do this was of course based on your ROOT and ROOT6 bing unaltered. But after I advised that, you came ack tellin that you changed named of ROOT6/bin/root and several other files there.
When I advice a and you in the meantime do b, c and d, the value of my advice becomes easily nullified.
I must add that I made a severe typing eror. In both cases there is an _ instead of a space betwwen the two asignments. The commands should read:
alias root="ROOTSYS=$HOME/ROOT PATH=$ROOTSYS/bin:$PATH $LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH $ROOTSYS/bin/root"
(in one line)
and
alias root6="ROOTSYS=$HOME/ROOT6 PATH=$ROOTSYS/bin:$PATH $LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH $ROOTSYS/bin/root"
(in one line)
And II assume it is better to add the full path to the command. But I do not have the product here and I asked you to test to enabble us to betttr those commandds with trial anderror. But you went on going different things. Thus this trial and error cycle takes more time.
Again, please try the above. It is btw not strange that root still functions with my trial, because you still have the old statments in your .bashrc. For the test it is better to comment them out for the moment.
I did try using the aliases you’ve suggested before I’ve made modifications.
Also, I “Copied” executable “~/ROOT6/bin/root” to root6, instead of renaming it. The changes should have been irrelevant even if I made modifications before testing.