hello ,
I'm not very good in scripts, but I'm getting nowhere even after reading all sort of infos concerning my script-problem.
I have a script, that queries a remote-system via ssh with "df -k". From that answer, I need to compare the returned value against a warning - and a critical threshold- supplied by parameters $3 and $4.
Thats the problem: (excerpt):
#!/bin/bash
#$1= remote IP
#$2= disk-name
#$3= warning-threshold
#$4= critical threshold
#$answ= return-message
if [ $# -ne 4 ]
then
echo "usage: "$0" <IP-Addr> <Disk-Name> <warn-thresh> <crit-thresh>
fi
free=`ssh -l root $1 df -k|grep $2|awk '{ print $ 5}'|cut -d "%" -f 1 -
used=`expr 100-$free`
>> following my line 23, complained in the err-mesage:<<
if [ "$3" -gt "$used" ]
then
answ="$used"
status=0
fi
.. Rest of code follows .....
Here, like with the rest of similar tests, I get the error:
expr: syntax error
./<prog-name>: line 23: [ : : integer expression expected.
But $3 as well as $used contain numbers.
Perhaps this is a good laugh for experts, but I have no idea how to solve this.
Any help is apreciated.
regards,
Fred.
I'm not very good in scripts, but I'm getting nowhere even after reading all sort of infos concerning my script-problem.
I have a script, that queries a remote-system via ssh with "df -k". From that answer, I need to compare the returned value against a warning - and a critical threshold- supplied by parameters $3 and $4.
Thats the problem: (excerpt):
#!/bin/bash
#$1= remote IP
#$2= disk-name
#$3= warning-threshold
#$4= critical threshold
#$answ= return-message
if [ $# -ne 4 ]
then
echo "usage: "$0" <IP-Addr> <Disk-Name> <warn-thresh> <crit-thresh>
fi
free=`ssh -l root $1 df -k|grep $2|awk '{ print $ 5}'|cut -d "%" -f 1 -
used=`expr 100-$free`
>> following my line 23, complained in the err-mesage:<<
if [ "$3" -gt "$used" ]
then
answ="$used"
status=0
fi
.. Rest of code follows .....
Here, like with the rest of similar tests, I get the error:
expr: syntax error
./<prog-name>: line 23: [ : : integer expression expected.
But $3 as well as $used contain numbers.
Perhaps this is a good laugh for experts, but I have no idea how to solve this.
Any help is apreciated.
regards,
Fred.