McKown, John wrote:
My mind is dying from sinuses. What I would like to do is change a subdirectory mentioned in the PATH variable with a different value. In particular, I have multiple JAVA releases installed. In /etc/profile, I set JAVA_HOME to the default directory and put JAVA_HOME/bin on the PATH. I would like to write a simple shell script which changes the current value of JAVA_HOME to a different value (easy) and change the JAVA_HOME/bin portion of the PATH to the "new" one, then invoke java. Something like:#!/bin/sh newhome="/java160" if [ ! -z $JAVA_HOME ]; then PATH=$(...) fi export JAVA_HOME=${newhome} export PATH={$PATH}:${newhome}/bin What I want in the ... portion is to erase ${JAVA_HOME}/bin along with appropriate semi-colon separator (i.e. trailing if JAVA_HOME/bin is the first on the list, otherwise leading). I was thinking of something like sed, but just cannot get my brain to work very well today. Should I just give up and not set a default, but create a "java" shell script to invoke java? Oh, and I guess the same for javac, but that is not as critical for me. What I really wish that I could do would be to "source" some file which would do the same so that the "default" java for that user would be changed until some over "java selection" script was sourced. Is this possible? Thanks for any ideas. Maybe if I get over this sinus attack next week, I may figure it out myself.
Depending on your distro, That kind of hackery should be in /etc/profile.d, where you can easily switch from one to another with minimum risk of side effects - disable one, enable the other. You should also look at /etc/alternatives* - both Debian and RH use this. Rather than ~/bin as a symlink, I suggest ~/javabin as ~/bin is a common place for users private binaries, scripts and such, and I'd not want that being hijacked if I were one of your users. For new users, you could add to /etc/skel Folk with Linux on their desktop can set different sessions in konsole, and I'm sure they can create different ones for different versions of java. Or manually source something that changes it for _this_ session. -- Cheers John -- spambait [EMAIL PROTECTED] [EMAIL PROTECTED] Please do not reply off-list ---------------------------------------------------------------------- For LINUX-390 subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit http://www.marist.edu/htbin/wlvindex?LINUX-390
