Solved

Need help in checking an rpm and install or uninstall it

Posted on 2016-08-06
3
78 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
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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 …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

825 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