Ad Widget

Collapse

Problems with bash script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yasypol
    Junior Member
    • Apr 2008
    • 1

    #1

    Problems with bash script

    Hi all,

    I'm trying to use a bash script to know when a host needs updates. I executed it doing

    ./script_name

    and the result is ok.

    But when it is monitorized in zabbix, the returned values are wrong when looking at the item history. Something strange is happening, like it always evaluates the condition to false.

    Here is the script

    #!/bin/bash

    apt-get update

    if [ $(apt-get dist-upgrade -V -s | grep "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded") ]
    then
    echo 9
    else
    echo 5
    fi


    For example, when I do ./script_name, the returned value is 9, but at the same time, in bash history the returned value is 5.

    Somebody can help me please? I don't understand what's happening.
Working...