BashScripts.org
http://bashscripts.org/forum/

if a certain rpm isn't installed, the script will fail
http://bashscripts.org/forum/viewtopic.php?f=8&t=1424
Page 1 of 1

Author:  dagummit [ Fri Jul 01, 2011 12:32 pm ]
Post subject:  if a certain rpm isn't installed, the script will fail

I need help in making it where if a certain RPM isn't installed, the script will fail to continue. I have started to use an if else statement, but not really sure on how to properly set it up. The RPM in question is logwatch. I have also thought about doing something with rpm -qa | grep logwatch, but that returns the version number of the RPM along with it...and other machines might have a different version, which is okay and the script should continue to run if that is the case.

Any ideas? Thanks!

Author:  jsz [ Fri Jul 01, 2011 4:16 pm ]
Post subject:  Re: if a certain rpm isn't installed, the script will fail

The code below will print an error message to STDERR saying that logwatch(1) isn't installed, then exit with 1 as exit code to tell the shell that an error occured.

Code:
if ! type -p logwatch > /dev/null; then
    printf 'E: logwatch(1) is not installed on your system.\n' >&2
    exit 1
fi


If you did further searches you'd have found this post which describes the same issue.

Author:  dagummit [ Wed Jul 06, 2011 5:38 pm ]
Post subject:  Re: if a certain rpm isn't installed, the script will fail

thanks! I'll try this out...

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com