From: mostro713 on
Hi all,

I am trying to put together a simple script that will send an email
when disk space falls below a certain percentage. I'm receiving an
error "24: integer expression expected". From what I read it has to do
with -lt thinking the values in brackets are not integers. Aren't
they? Can you provide me with some assistance.

#!/bin/bash

disk=`df -h -x cifs -x iso9660 | grep -E ^/dev | awk '{ print $4 }' |
sed 's/G//g'`

#[Loop]

for i in $disk
do
if [ "$disk" -lt 20 ]; then
echo "Error"
<send email goes here>
fi
done

Thanks in advance
From: Chris F.A. Johnson on
On 2007-11-17, mostro713(a)gmail.com wrote:
>
> I am trying to put together a simple script that will send an email
> when disk space falls below a certain percentage. I'm receiving an
> error "24: integer expression expected". From what I read it has to do
> with -lt thinking the values in brackets are not integers. Aren't
> they?

Are they? Have you looked at the output of 'df -h'?

> Can you provide me with some assistance.
>
> #!/bin/bash
>
> disk=`df -h -x cifs -x iso9660 | grep -E ^/dev | awk '{ print $4 }' |
> sed 's/G//g'`
>
> #[Loop]
>
> for i in $disk
> do
> if [ "$disk" -lt 20 ]; then

You should be comparing $i, not $disk.

> echo "Error"
> <send email goes here>
> fi
> done

min=20000000
df -x cifs -x iso9660 |
while read fs bl u a pc mp
do
if [ "$a" -lt "$min" ]
then
echo "Error"
...
fi
done


--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
From: mostro713 on
On Nov 16, 8:35 pm, "Chris F.A. Johnson" <cfajohn...(a)gmail.com> wrote:
> On 2007-11-17, mostro...(a)gmail.com wrote:
>
> > I am trying to put together a simple script that will send an email
> > when disk space falls below a certain percentage. I'm receiving an
> > error "24: integer expression expected". From what I read it has to do
> > with -lt thinking the values in brackets are not integers. Aren't
> > they?
>
> Are they? Have you looked at the output of 'df -h'?
>
> > Can you provide me with some assistance.
>
> > #!/bin/bash
>
> > disk=`df -h -x cifs -x iso9660 | grep -E ^/dev | awk '{ print $4 }' |
> > sed 's/G//g'`
>
> > #[Loop]
>
> > for i in $disk
> > do
> > if [ "$disk" -lt 20 ]; then
>
> You should be comparing $i, not $disk.
>
> > echo "Error"
> > <send email goes here>
> > fi
> > done
>
> min=20000000
> df -x cifs -x iso9660 |
> while read fs bl u a pc mp
> do
> if [ "$a" -lt "$min" ]
> then
> echo "Error"
> ...
> fi
> done
>
> --
> Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> ===== My code in this post, if any, assumes the POSIX locale
> ===== and is released under the GNU General Public Licence

Yes, what a mistake... Changing $disk for $i makes a huge
difference..:)
A second pair of eyes always helps..

Thank you...