Register
It is currently Wed Apr 23, 2014 1:36 pm

if a certain rpm isn't installed, the script will fail


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Fri Jul 01, 2011 12:32 pm   

Joined: Tue Apr 19, 2011 11:01 pm
Posts: 36
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!


Top
 Profile  
 PostPosted: Fri Jul 01, 2011 4:16 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
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.


Top
 Profile  
 PostPosted: Wed Jul 06, 2011 5:38 pm   

Joined: Tue Apr 19, 2011 11:01 pm
Posts: 36
thanks! I'll try this out...


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP