Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple scripting question

Status
Not open for further replies.
Oct 9, 2003
174
US
good morning everyone, need some assistance please.

I am looking to write a script to take each partition and do a disk space check to see if the used space is over 98% of the disk. This is what I have.

par="u01 u02 u03 u04 u05 u06 rootvol"
size=""
for y in $par ; do
df -k | grep $y | awk '{print $5}' | nawk -F '%' '{print $1}' > $size
if [ $size -ge "98" ]; then
echo "$par is growing out of control" >> $MYMSG
else
goto EXIT
fi
done


when run, i am getting this error. is there another way to do this??

./tt2[7]: test: argument expected
73
./tt2[7]: test: argument expected
64
./tt2[7]: test: argument expected
70
./tt2[7]: test: argument expected
53
./tt2[7]: test: argument expected
91
./tt2[7]: test: argument expected
13
./tt2[7]: test: argument expected

 
got it, thanks.

#!/bin/ksh
#
par="u01 u02 u03 u04 u05 u06 rootvol"
size=""
for y in $par ; do
if [ `df -k | grep $y | awk '{print $5}' | nawk -F '%' '{print $1}'` -ge "98" ]; then
echo "$y is growing out of control"
else
goto EXIT
fi
done
 

try something like this.
there's no 'goto' in ksh
Code:
#!/bin/ksh

par="u01 u02 u03 u04 u05 u06 rootvol"
typeset -i size=0
typeset -i thr=98

for y in $par ; do
      size=$(df -k | grep $y | awk '{print $5}' | nawk -F '%' '{print $1}')
      if (( $size >= $thr )); then
         echo "$par is growing out of control" >> $MYMSG
       else
          break;
      fi
done

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks, the whole goto thing not working was my next question. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top