Bash if statement equal output from last command

Posted by mYzk on Server Fault See other posts from Server Fault or by mYzk
Published on 2014-06-02T14:04:43Z Indexed on 2014/06/02 15:31 UTC
Read the original article Hit count: 346

Filed under:
|

I am trying to equal something from last command with bash if statement:

#!/bin/bash

monit status

if [ "status" != "error" ]; then
        echo -e "hostname\ttest\t0\t0" | /usr/sbin/send_nsca -H hostname -c /etc/send_nsca.cfg
        exit 1;
fi

Even if the monit status gives out status = online with all services it runs the echo command. I can not figure out how to make the if statement match the status of monit status output.

© Server Fault or respective owner

Related posts about bash

Related posts about scripting