read list of installed softwares in linux using java program
Maan Suraj
Ranch Hand
Joined: Dec 20, 2007
Posts: 289
posted
0
I want to write a java program which runs on a linux machine,and this java program should give the list of installed rpms on that machine. I am not sure what is to be done. I also gone through the site which tells how to "http://www.codeproject.com/KB/files/CoolCode.aspx" read the list of sofware's installed on windows. I want something similar for my linux machine.
Any information on this would be great...
Man Suraj
Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"
It would be hard to do that in Java, because RPM's are not merely OS-specific, they're specific to only certain Linux distros. Debian and Ubuntu, for example, use ".deb" packages, instead.
However, it's a trivial task to get the list of installed RPM's. In many releases, it's kept in /var/log/rpmpkgs, although interestingly, I see that Fedora 14 isn't one of them.
For systems where that file isn't available, you can simply query RPM itself with the "rpm -qa" command and read the stdout stream. If the basic package name isn't sufficient and you want refinements like the actual release, there are additional options. This is the one that builds /var/log/rpmpkgs:
The actual cron job sorts the results using the "sort" utility.
Customer surveys are for companies who didn't pay proper attention to begin with.
Maan Suraj
Ranch Hand
Joined: Dec 20, 2007
Posts: 289
posted
0
Thanks Tim,
So i believe what i should do is run something like this below?
I don't really see the purpose of using Java for doing this, since after all you end up just execing a process from Java. What's the requirement for using Java?
And you never said what kind of display!
If displaying on the command line, then writing a Java app is useless - use Tim's one-liner instead.
If displaying in a web browser or in a GUI, then Java will be helpful in formatting the display, though you would still use Tim's one-liner to gather the data.