?
Solved

Need help in checking an rpm and install or uninstall it

Posted on 2016-08-06
3
Medium Priority
?
109 Views
Last Modified: 2016-09-09
Hi all ,

I am able to check the rpm of it installed or not and send the report but I would like to add option that if rpm present of not then I can install or uninstall it as per need.

Thanks to help !
0
Comment
Question by:The Rock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 2000 total points
ID: 41745978
You could have something like:
# $rpmname is name of rpm to manage
if rpm -qa | grep -q $rpmname; then
  echo "rpm $rpmname is installed"
  echo "Do you want to uninstall it?"
  read ans
  if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then
    rpm -e $rpmname
  fi
else
  # repeat above but offer to install rpm
fi

Open in new window

This assumes that the response is "y" or "Y" for "yes", and anything else means "no".
0
 

Author Comment

by:The Rock
ID: 41746109
Thank you Simon - will try this week as I am on leave for few days .
0
 

Author Closing Comment

by:The Rock
ID: 41791091
Thanks Simon it works as I wnated.

Thank you!
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question