[Tutor] How to Compare rpm version using Python Script

Alex Kleider akleider at sonic.net
Fri Nov 29 12:06:18 EST 2019


On 2019-11-29 04:32, Asad wrote:
> Hi All ,
> 
>            I am thinking to write a script to compare the rpm version
> installed in a Linux system with a defined list of the rpm's . It the
> elements matches or the system has a higher version show success or 
> else
> show failed .
> 
> I was planning to use the rpm command :
> 
> /bin/rpm -q --queryformat '%{name}-%{ARCH}-%{version}-%{release}\n'
> 
> to get the list of rpm's installed in the system . How to do the 
> comparison
> for example :
> 
> Expected Value:compat-libcap1-1.10
> INFO: Actual Value:compat-libcap1-1.10-7.el7
> 
> This should show success .
> 
> Please share some knowledge and logic to code this .
> 
> Thanks,

The following _might_ help you get started:

>>> "hello" in "hello world"
True
>>> 


More information about the Tutor mailing list