CaptainMark
October 24th, 2012, 06:40 PM
I need a little help with a bash script, I think I'll always be a beginner on it buts it only a tiny hobby so I wont beat myself up over asking for help on this one,
Basically my question is how can I have bash script with an if statement that will only execute if a certain package is installed, so far I have this much which doesn't yet work
if [ $"dpkg-query -l qdbus" ]; then echo success; fiI was hoping that if the package qdbus was not installed then the statement would evaluate to false and the "then echo success" would not run, but it runs regardless of what I type here, is there a way of bash evaluating an if statement and basically say "If this command gives an error then evaluate to false"
Alternatively I could append 2>/dev/null to the command and basically ask bash "If this command gives any output, evaluate to true, otherwise evaluate to false"
I hope I've explained myself well. If not please ask me any questions
Thanks for any help you offer
Mark
Basically my question is how can I have bash script with an if statement that will only execute if a certain package is installed, so far I have this much which doesn't yet work
if [ $"dpkg-query -l qdbus" ]; then echo success; fiI was hoping that if the package qdbus was not installed then the statement would evaluate to false and the "then echo success" would not run, but it runs regardless of what I type here, is there a way of bash evaluating an if statement and basically say "If this command gives an error then evaluate to false"
Alternatively I could append 2>/dev/null to the command and basically ask bash "If this command gives any output, evaluate to true, otherwise evaluate to false"
I hope I've explained myself well. If not please ask me any questions
Thanks for any help you offer
Mark