![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help needed in search string | amitrajvarma | UNIX for Dummies Questions & Answers | 2 | 11-22-2007 05:16 AM |
| Help needed in string manipulation | haifrancis | Shell Programming and Scripting | 4 | 09-08-2006 09:21 AM |
| something about <math.h> | blf0 | High Level Programming | 4 | 03-10-2006 12:44 AM |
| Help needed - Replacing all date & time occurrences in a file with a string using Sed | Hema_M | Shell Programming and Scripting | 4 | 11-17-2005 01:42 AM |
| Help needed in String manipulation | ramanan | Shell Programming and Scripting | 2 | 08-24-2005 04:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
String math help needed
Code:
#!/usr/bin/ksh
#LOGFILE=/var/opt/ixos/log/notification_warning.log
#DAT1=/var/opt/ixos/monitor/percentages.dat
#DAT2=/var/opt/ixos/monitor/mountpoints.dat
THRESHOLD=75
#`rm $DAT1`
#`rm $DAT2`
`bdf | grep /var/opt/ixos | awk '{ print $4 }' | cut -f1 -d"%" > test.dat` `bdf | grep /var/opt/ixos | awk '{ print $5 }' > test2.dat`
set -A PERCENTAGES `cat test.dat`
set -A MOUNTPOINTS `cat test2.dat`
len=${#PERCENTAGES[*]}
i=0
while [ $i -lt $len ] do
value=${PERCENTAGES[$i]}
if ( $value > $THRESHOLD ) then
echo "${MOUNTPOINTS[$i]} IS ${PERCENTAGES[$i]}% FULL RIGHT NOW....please increase the space soon."
fi
(( i=i+1 ))
done
exit 0
The above is working just fine for me except that the $value > $THRESHOLD comparison fails. PERCENTAGES is simply an array of numbers (actually strings) that I want to cue off of and only write a line to a log file if the value is above whatever THRESHOLD is set to. Sounds easy enough but apparently shell script math and I don't get along. Any help is appreciated. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|