LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-29-2006, 07:56 AM   #1
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Rep: Reputation: 15
Question How to Update a Batch of Sym Links?


Hi all,

i have the following symlinks in my /etc/alternatives directory, amongst others:

Code:
lrwxrwxrwx 1 root root  35 2006-10-27 10:52 jar -> /usr/lib/jvm/java-1.5.0-sun/bin/jar
lrwxrwxrwx 1 root root  54 2006-10-27 10:52 jar.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jar.1.gz
lrwxrwxrwx 1 root root  41 2006-10-27 10:52 jarsigner -> /usr/lib/jvm/java-1.5.0-sun/bin/jarsigner
lrwxrwxrwx 1 root root  60 2006-10-27 10:52 jarsigner.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jarsigner.1.gz
lrwxrwxrwx 1 root root  40 2006-10-27 10:16 java -> /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
lrwxrwxrwx 1 root root  59 2006-10-27 10:16 java.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/jre/man/man1/java.1.gz
lrwxrwxrwx 1 root root  37 2006-10-27 10:52 javac -> /usr/lib/jvm/java-1.5.0-sun/bin/javac
lrwxrwxrwx 1 root root  56 2006-10-27 10:52 javac.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/javac.1.gz
lrwxrwxrwx 1 root root  39 2006-10-27 10:52 javadoc -> /usr/lib/jvm/java-1.5.0-sun/bin/javadoc
lrwxrwxrwx 1 root root  58 2006-10-27 10:52 javadoc.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/javadoc.1.gz
lrwxrwxrwx 1 root root  37 2006-10-27 10:52 javah -> /usr/lib/jvm/java-1.5.0-sun/bin/javah
lrwxrwxrwx 1 root root  56 2006-10-27 10:52 javah.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/javah.1.gz
lrwxrwxrwx 1 root root  37 2006-10-27 10:52 javap -> /usr/lib/jvm/java-1.5.0-sun/bin/javap
lrwxrwxrwx 1 root root  56 2006-10-27 10:52 javap.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/javap.1.gz
lrwxrwxrwx 1 root root  44 2006-10-27 10:52 java-rmi.cgi -> /usr/lib/jvm/java-1.5.0-sun/bin/java-rmi.cgi
lrwxrwxrwx 1 root root  43 2006-10-27 10:16 java_vm -> /usr/lib/jvm/java-1.5.0-sun/jre/bin/java_vm
lrwxrwxrwx 1 root root  42 2006-10-27 10:16 javaws -> /usr/lib/jvm/java-1.5.0-sun/jre/bin/javaws
lrwxrwxrwx 1 root root  61 2006-10-27 10:16 javaws.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/jre/man/man1/javaws.1.gz
lrwxrwxrwx 1 root root  40 2006-10-27 10:52 jconsole -> /usr/lib/jvm/java-1.5.0-sun/bin/jconsole
lrwxrwxrwx 1 root root  59 2006-10-27 10:52 jconsole.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jconsole.1.gz
lrwxrwxrwx 1 root root  35 2006-10-27 10:52 jdb -> /usr/lib/jvm/java-1.5.0-sun/bin/jdb
lrwxrwxrwx 1 root root  54 2006-10-27 10:52 jdb.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jdb.1.gz
lrwxrwxrwx 1 root root  37 2006-10-27 10:52 jinfo -> /usr/lib/jvm/java-1.5.0-sun/bin/jinfo
lrwxrwxrwx 1 root root  56 2006-10-27 10:52 jinfo.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jinfo.1.gz
lrwxrwxrwx 1 root root  36 2006-10-27 10:52 jmap -> /usr/lib/jvm/java-1.5.0-sun/bin/jmap
lrwxrwxrwx 1 root root  55 2006-10-27 10:52 jmap.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jmap.1.gz
lrwxrwxrwx 1 root root  35 2006-10-27 10:52 jps -> /usr/lib/jvm/java-1.5.0-sun/bin/jps
lrwxrwxrwx 1 root root  54 2006-10-27 10:52 jps.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jps.1.gz
lrwxrwxrwx 1 root root  41 2006-10-27 10:52 jsadebugd -> /usr/lib/jvm/java-1.5.0-sun/bin/jsadebugd
lrwxrwxrwx 1 root root  60 2006-10-27 10:52 jsadebugd.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jsadebugd.1.gz
lrwxrwxrwx 1 root root  38 2006-10-27 10:52 jstack -> /usr/lib/jvm/java-1.5.0-sun/bin/jstack
lrwxrwxrwx 1 root root  57 2006-10-27 10:52 jstack.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jstack.1.gz
lrwxrwxrwx 1 root root  37 2006-10-27 10:52 jstat -> /usr/lib/jvm/java-1.5.0-sun/bin/jstat
lrwxrwxrwx 1 root root  56 2006-10-27 10:52 jstat.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jstat.1.gz
lrwxrwxrwx 1 root root  38 2006-10-27 10:52 jstatd -> /usr/lib/jvm/java-1.5.0-sun/bin/jstatd
lrwxrwxrwx 1 root root  57 2006-10-27 10:52 jstatd.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/man/man1/jstatd.1.gz
lrwxrwxrwx 1 root root  43 2006-10-27 10:16 keytool -> /usr/lib/jvm/java-1.5.0-sun/jre/bin/keytool
lrwxrwxrwx 1 root root  62 2006-10-27 10:16 keytool.1.gz -> /usr/lib/jvm/java-1.5.0-sun-1.5.0.08/jre/man/man1/keytool.1.gz
Recently, i downloaded version 1.5.0_09 of the JDK and installed it in /opt/jdk1.5.0_09.

Hence, i would like to update all the related symlinks in /etc/alternatives to point to /opt/jdk1.5.0_09 instead of /usr/lib/jvm/java-1.5.0-sun-1.5.0.08.

How can i easily do this?

i was trying to hack together a bash script to do this, and my first step was to pipe "ls -l" to "grep" to get the lines that contain "/usr/lib/jvm/java-1.5.0-sun-1.5.0.08", but ran into a problem when trying to pass the result of "grep" into a for-in loop to do more processing. Apparently the result gets tokenized by all white spaces when passed into the for-in loop.

In any case, is there an easier way to do this without having to put together a complicated shell script?



TIA and Regards,
Edwin
 
Old 11-29-2006, 08:02 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Install galternatives and run it. This gives you a nice GUI for setting alternatives.
 
Old 11-30-2006, 07:49 AM   #3
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Original Poster
Rep: Reputation: 15
Thanks Matthew,

i tried using galternatives, but seems like it still requires me to change all the symlinks one by one (unless i'm using it wrongly), so it's not really much better than doing it from command line.



 
Old 11-30-2006, 08:21 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Oops, I mis-read the original post.

If it was a one-time thing, I would probably generate a script from the ls -l output, check the script and then execute it. For example:
Code:
cd /etc/alternatives
ls -l | grep postgresql | sed 's!postgresql/8.1!postgresql/8.2!' | awk '{ print "update-alternatives --set " $8 " " $10 }' > /tmp/alt_updater
and check that /tmp/alt_updater contains commands which work, and that it affects the right items, and then execute it using:
Code:
sudo bash /tmp/alt_updater
I used postgres in my example because I don't have the java stuff installed. It should e easy to modify for your purposes.

One last thing - I didn't check that I'm using the correct syntax for update-alternatives - I always use galternatives. Do a test first!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sym links and permissions emme0032 Linux - Newbie 2 11-18-2006 02:26 AM
Sym links and hard links akudewan Linux - Newbie 4 02-09-2005 05:08 AM
Dead sym links Hangdog42 Linux - General 5 10-02-2003 04:35 AM
Sym Links and vsFTPd Datacraft Linux - Software 1 05-24-2003 05:20 PM
dead sym links dewcansam Linux - General 1 02-08-2002 04:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration