LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices

Reply
 
Search this Thread
Old 10-30-2012, 06:54 PM   #1
linux098
LQ Newbie
 
Registered: Oct 2012
Posts: 6

Rep: Reputation: Disabled
Function block usage in Shell script to UnInstall Specific packages


Hi Team,

I need to write a shell script to do the following. I'm installting software packages using an install script but, my installation fails because the machine has traces of old installations. So I need verify installed old packages (lslpp) and then uninstall the old packages (installp -u) and then continue to the install script.

Suppose my installation packages are

ABC.lic
ABC.xyz
ABC.123
ABC.rte
ABC.jrte



when I do a lsllp -l | grep 'ABC'

I'll get all the packages installed with ABC in the package name. If the reason code is 0 it means there are traces of previous installations. So before installing the new packages I need to unstall the old packages.

installp -u ABC.lic
installp -u ABC.xyz
installp -u ABC.123
installp -u ABC.rte
installp -u ABC.jrte


But my problem is not every machine will have all the above packages installed. Some machine might have only packages ABC.lic and ABC.xyz while other might have ABC.rte and ABC.jrte. or some machine might have only ABC.jrte

So I need to identify exactly what packages are installed and just uninstall only those packages. I cannot use installp -u *ABC* as that might uninstall packages related to antoher software package.

Instead of writing lengthy if else loops to find the installed software can I use an uninstall function in my script and pass the installed packages as variables.

Could anyone of you please suggest me how I can wrtie my function block and call it to unistall only specifc packages or please suggest me if there is better way to accomplish this task.

Anyhelp is greatly appreciated!
 
Old 11-01-2012, 01:19 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 281

Rep: Reputation: 118Reputation: 118
Hi there,

A few quick suggestions.

Firstly, I'd advise against using "lsllp -l | grep 'ABC'" just in case 'ABC' appears in a description rather than a fileset name somewhere. "lslpp -l '*ABC*'" avoids that.

Next you can get to the fileset names only by running:
Code:
lslpp -Lc '*ABC*' | awk 'BEGIN {FS=":"} !/^#/ {print $1}'
Lastly you can remove these one at a time with the help of xargs. Try this first to test that it produces the desired commands:
Code:
lslpp -Lc '*ABC*' | awk 'BEGIN {FS=":"} !/^#/ {print $1}' | xargs -n1 echo lslpp -u
If it works, just remove the "echo" and you're good to go.

Good luck!

Last edited by cliffordw; 11-01-2012 at 01:21 AM. Reason: fixed minor typos
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
cd command usage a in shell script using bash chuckt6 Linux - Newbie 5 04-21-2012 12:44 PM
[SOLVED] Problem With Shell Script Variable Usage Crowey Linux - General 2 02-09-2010 02:03 AM
shell script? : usage of $! with su -c option DTParanoia Linux - General 3 04-05-2005 06:58 PM
How do I uninstall packages in shell? Borg Swarm Linux - Newbie 1 01-22-2004 06:27 PM
Uninstall a shell script? (Crossover Office) Trinity22 Linux - Software 3 12-09-2003 03:37 PM


All times are GMT -5. The time now is 08:05 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration