I am trying to create a event handler for icing. My Bash script looks like this right now:
#!/bin/bash
# Event Handler for loggin out inactive RDP users
# $1 is $SERVICESTATE$ (OK WARNING UNKNOWN CRITICAL)
# $2 is $SERVICESTATETYPE$ (SOFT HARD)
# $3 is $SERVICEATTEMPT$ (1 through 4)
# $4 is $SERVICDOWNTIME$ (0 no Downtime, >0 Downtime active)
# $5 is SRV29
# $6 is $host.name$ (1 through 4)
if [ "$4" > 0 ];
echo "in downtime, exit";
then exit
fi
case "$1" in
OK)
echo "ok!"
;;
WARNING)
echo "warning!"
;;
UNKNOWN)
echo "unknown!"
;;
CRITICAL)
echo "critical!"
...
When I execute this script without my if statement at the top, everything works fine. But I want to check if $4 is greater than 0. This test condition always returns true and no matter what I enter inside this condition it always results in "in downtime, exit".
So even if [ "hello" = "hallo" ] it will go inside and exit right away.
I also tried pretty much every variation with quotes, without, double brackets... and so on.
I am obviously doing something wrong. Can anyone spot it?
Thanks in advance!
>inside[...], it means redirection there. In some shells, you can use\>, or better to use standard one-gt.# $4 is $SERVICDOWNTIME$ (1 through 4), so it's always true, isn't it?ifstatement's syntax first. thethenmust be attached like as:if [ "$4" -gt 4 ]; then