The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2007
petachi petachi is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 2
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.
  #2 (permalink)  
Old 09-29-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Try to substitute this:


Code:
if ( $value > $THRESHOLD ) then

with this:


Code:
if [ $value -gt $THRESHOLD ] then

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0