PATH question (newbie)
ZIYAD A. M. AL-BATLY
zamb at spymac.com
Mon Apr 18 05:48:22 UTC 2005
On Sun, 2005-04-17 at 23:34 -0400, Matthew S-H wrote:
> I followed your advice on this one and it seems to work pretty much
> fine. I changed the line a bit though:
> "PATH=$PATH:$(echo /opt/*/bin|sed -e 's/ /:/g'); PATH=$PATH: $(echo
> /opt/*/*.bin|sed -e 's/ /:/g')"
>
> I did this because I had Java installed at "/opt/jre1.5.0_02". The
> binaries are in "/opt/jre1.5.0_02/bin/", and they are called "java",
> "java_vm", and "javaws".
>
> Here are my questions/problems:
> When I use this, it also includes all of the other binaries in that
> folder. I don't want there to be binaries such as "ControlPanel",
> "klist", "kinit", "orbd", etc. in my PATH. What can I o to include
> only some of the binaries in that folder?
>
> Also, just as an idea, what about creating a subdirectory of /opt/
> called something like "symbolic_links" and creating symbolic links to
> all the executables in the other folders of /opt/? I wouldn't mind
> creating a new symbolic link each time I installed a new piece of
> software. The only problem I can think of with this idea is that I am
> not quite sure how to create a symbolic link. I know it involves "ln",
> but I am not quite sure which parameters I should use.
>
>
> Anyway, thanks for your help.
>
> ~Matt
>
The best solution that fits your needs would be to create a shell script
for the binary(s) you want to be present in $PATH. Here is an example
for "/opt/jre1.5.0_02/bin/java":
/bin/sh
cd /opt/jre1.5.0_02/bin || exit 1
exec ./jave "$@"
Put it in "/opt/bin" (for example) and make it executable:
chmod a+x /opt/bin/java
Do this for the rest of the files you want.
That being said, you might have luck by linking the binaries (just as
you asked). Here is an example:
ln -s /opt/jre1.5.0_02/bin/java /opt/bin/java
(In both example you need to include "/opt/bin" in your $PATH. Or you
could create the script/link in "/usr/loca/bin" which is included by
default in PATH.)
Why did I say "you might have luck" above? Will, depending on the
executable you're dealing with, linking might or might not work. Just
try linking first (as it's easier) then fall back to the shell script.
(As a simple rule, If the executable being questioned is *itself* a
shell script (like firefox and java if I'm not mistaken) then linking
should be enough. To tell if it's a shell script or not run:
file /opt/jre1.5.0_02/bin/java
and see what it tells you.)
Ziyad.
More information about the ubuntu-users
mailing list