Bash Script Outputting Null

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
EnderXncdr
Posts: 4
Joined: Thu Jan 14, 2016 9:26 am

Bash Script Outputting Null

Post by EnderXncdr »

I am running a local script and it works just fine when running manually.

#!/bin/bash

printer=$1

#--------------------------------#
# Query UPH value for printer

get_uph=$(grep $1 MULTIS.csv)
full_uph=$(echo $get_uph | cut -d "," -f12)
uph=$(printf "%.0f\n" $full_uph)

#--------------------------------#
if [ "$uph" -eq "0" ]; then
echo "OK: $uph"
exit 0
fi
if (( $uph > 84 )); then
echo $uph
exit 0
fi
if [ "$uph" -eq "84" ]; then
echo $uph
exit 1
fi
if (( $uph < 84 )); then
echo $uph
exit 2
fi

What happens is the output variable equals 0,no matter what it actually is. Are there any characters in the script it doesn't like? Here is what the command looks like.

define command {
command_name multisuph
command_line $USER1$/multis_uph.sh $HOSTNAME$
}
EnderXncdr
Posts: 4
Joined: Thu Jan 14, 2016 9:26 am

Re: Bash Script Outputting Null

Post by EnderXncdr »

This can be closed. I figured it out. You have to put the full path to the csv file for it to work. Bang my head against a wall for 24 hours and it is that simple.
Locked