?
Solved

Need help in checking an rpm and install or uninstall it

Posted on 2016-08-06
3
Medium Priority
?
117 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 20

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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Utilizing an array to gracefully append to a list of EmailAddresses
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.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

649 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