LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-10-2015, 02:48 AM   #1
jaykbvt
LQ Newbie
 
Registered: Feb 2015
Posts: 3

Rep: Reputation: Disabled
script for software inventory


Hi Guys,

I'm trying to write a script which can give me a list of installed packages in csv format.

In windows I can query registry keys or ask wmi for installed products.

I'm using CentOS so I thought of usning

yum info installed

its gr8 gives all the info but it gives info in its own format...like given below..

=======================

Name : ConsoleKit
Arch : x86_64
Version : 0.4.1
Release : 3.el6
Size : 263 k
Repo : installed
From repo : anaconda-CentOS-201311272149.x86_64
Summary : System daemon for tracking users, sessions and seats
URL : http://www.freedesktop.org/wiki/Software/ConsoleKit
License : GPLv2+
Description : ConsoleKit is a system daemon for tracking what users are logged
: into the system and how they interact with the computer (e.g.
: which keyboard and mouse they use).
:
: It provides asynchronous notification via the system message bus.


=======================

Is there any way possible to get only Name, Version, Release, Size, Repo, Summary, URL,Licence in a csv file...???

Probably with combination of awk, sed, grep...??

Or should I use any other approach to get software inventory...??


--
Thanks & Regards,
jaykbvt
 
Old 02-10-2015, 12:29 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,788
Blog Entries: 13

Rep: Reputation: 4831Reputation: 4831Reputation: 4831Reputation: 4831Reputation: 4831Reputation: 4831Reputation: 4831Reputation: 4831Reputation: 4831Reputation: 4831Reputation: 4831
The way I would do it would be via script and using any of the utilities which you've mentioned.

Basically for a script, you can do anything in the script which you can do in the command line, so if you run that command and use awk, sed, and/or grep to process the output, you can use those same commands in a script. A brute force tactic would be to get the output of the command into one large sting or array of strings and then process that entity repeatedly to grab each desired attribute which you'd save into disparate variables. Then at the end of the parsing, you can output that into another file via the echo command and use comma separations. Once you get it right for one package report, you can then structure it to be a loop and make a set of arrays and then print them all out after the parse phase is complete. Or you could just not bother with arrays and just add one line to the output file each time you process a new package. I like that second option better because if for some reason the package report command locks up, you at least get some output.

There are links for BASH programming in my signature. I also have a blog entry with some suggestions how to code and debug BASH scripts.

If you get some interim results but get stuck, post your efforts and people will likely offer suggestions for improvements or solutions.
 
Old 02-11-2015, 01:30 AM   #3
jaykbvt
LQ Newbie
 
Registered: Feb 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks for reply..

Is there any management interface in linux,like WMI in Windows, which can be scripted..?




--
Thanks & Regards,
jaykbvt
 
Old 02-11-2015, 04:39 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,241

Rep: Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713
No idea what WMI is but if you run
Code:
rpm --querytags
I think you'll be pleasantly surprised

Here's an example of how to use it
Code:
rpm -qa 'kernel*' --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n"
 
Old 02-11-2015, 05:39 AM   #5
jaykbvt
LQ Newbie
 
Registered: Feb 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thumbs up

Oh gr8 man....!!!

Thats what I was looking for...!!

It matches my requirement perfectly..

Just a query...does rpm cover all the software packages installed...?? Or is there any other way also to install which can't be reported through this command..??

like there a huge difference between number of packages reported by both command.

==================================
[root@srv1 ~]# yum list installed |wc
1672 3526 113464
[root@srv1 ~]# rpm -qa | wc
1175 1175 39819
[root@srv1 ~]#

==================================


--
Thanks & Regards,
jaykbvt

Last edited by jaykbvt; 02-11-2015 at 05:44 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
inventory software aksharb Linux - Software 3 07-21-2013 02:07 AM
Linux Inventory Software robert_mckee Linux - Newbie 3 03-31-2012 11:01 PM
LXer: OpenLogic Announces Free Software to Inventory Installed Open Source Software LXer Syndicated Linux News 0 05-01-2007 01:01 AM
inventory software for abebook DropSig Linux - Software 3 10-17-2005 02:20 PM
Network Inventory and Software Distribution Software? tonyfreeman General 1 09-25-2004 05:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration