On Sat, Jun 22, 2002 at 07:08:00PM +0200, Andreas Metzler wrote: > Hello, > Is there some canonical fast way to check in a script whether inn, > inn2 or cnews is installed on the system?
What dpkg does is parsing /var/lib/dpkg/status. I recommend using dpkg - its error prone to rely on an implicit data format of the status file. If you look in the file, there is a paragraph for each package. What you want is searching the Packages: line, then search its Status: line and see if its last entry is "installed". You could use awk to do this (replace <package> with your package name). Greetings, Bastian test.sh if awk -f test.awk /var/lib/dpkg/status; then echo "installed"; else echo "not installed"; fi test.awk /^Package: / { found = ($2=="<package>"); } /^Status: / { if (found) exit ($4!="installed"); } END { if (!found) exit 1; }
pgpUvhwQAYTLy.pgp
Description: PGP signature