LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rpm shell script (https://www.linuxquestions.org/questions/linux-newbie-8/rpm-shell-script-805335/)

linuxment 05-01-2010 01:11 PM

rpm shell script
 
hi all

i have a input text file contain 10 rpms and they are old versions
i need a shell script to check if these rpms is installed or not and if the
newer version is installed and i need all the results in one output text file
contain every rpm and its condition ( the same) or (new )or( not installed)

thanks in advance.

TB0ne 05-01-2010 01:53 PM

Quote:

Originally Posted by linuxment (Post 3953962)
hi all

i have a input text file contain 10 rpms and they are old versions
i need a shell script to check if these rpms is installed or not and if the
newer version is installed and i need all the results in one output text file
contain every rpm and its condition ( the same) or (new )or( not installed)

thanks in advance.

Ok, so what's your question?? You've told us what you want....if you're having trouble with a script you wrote, post it, and tell us where you're having problems, and we'll be glad to help. Be sure to tell us what version/distro of Linux, sample file(s), and your complete script as it exists so far.

If you are expecting someone to write this for you, you're in the wrong place.

kirukan 05-01-2010 02:02 PM

I hope, we can suggest to use yum, apt-get, etc. instead of this scripting

EricTRA 05-01-2010 02:06 PM

Hello and welcome to LinuxQuestions,

Is this by any chance homework? It sure sounds like it. Like TB0ne said, show us what you have written already and where it's failing and we might point you in the right direction. If you're starting out with scripting, read these guides:

Bash Guide for Beginners
Advanced Bash Scripting Guide

Kind regards,

Eric

kneetin 04-11-2012 11:42 AM

Hello Everyone,

As i have writen a script which check the rpm installed or not.

But instead of enter single rpm i want a file input in which all rpms list which need to check.

Please help. thanks in advance

#!/bin/bash -

uname -rv
bash --version
rpm --version

echo
P=${1?" must specify package name."}

rpm -qa "$P" > t1
my_size=$( wc -l < t1 )
echo " Size of report file is $my_size lines"

if [[ $( rpm -qa $P ) =~ ${P} ]]
# if [[ $( rpm -qa $P ) == *${P}* ]]
then
echo " Package $P is installed."
else
echo " Package $P not found."
fi

exit 0


All times are GMT -5. The time now is 08:12 PM.