[TriLUG] OT - script help

Ryan Leathers Ryan.Leathers at globalknowledge.com
Fri Jul 8 14:15:12 EDT 2005


Now there is an idea I hadn't thought of. Tom foolery with strings where one should use integers seems like a bad idea in general though. example:

testvariable=5
threshold=10

if [ "$threshold" \< "$testvariable" ]
then
  echo "Threshold $threshold is exceeded by value $testvariable" # or whatever
fi                          

The obvious problem is that when you compare values in ascii sort order
10 is less than 5, so you don't get the result you want

On the other hand, Warren's suggestion to match string length is probably a great way to go so long as the magic threshold value is always the flip from 99 to 100. 


-----Original Message-----
From: trilug-bounces at trilug.org on behalf of Warren Myers
Sent: Fri 7/8/2005 2:01 PM
To: Triangle Linux Users Group discussion list
Subject: Re: [TriLUG] OT - script help
 
Couldn't you also just match the string length exceeding 2? by definition, a 
3 character string must be an int at least 100 (presuming it's a number).

WMM

On 7/8/05, Ryan Leathers <Ryan.Leathers at globalknowledge.com> wrote:
> 
> just convert the resulting string to an integer so you can compare to see 
> if its larger than your threshold.
> 
> 
> -----Original Message-----
> From: trilug-bounces at trilug.org on behalf of Howard Boyd
> Sent: Fri 7/8/2005 12:52 PM
> To: trilug at trilug.org
> Subject: [TriLUG] OT - script help
> 
> Could use some help w/ a simple script problem. I have written a simple
> script that will output the following line:
> 
> QUEUE(IN.TECH.Q) CURDEPTH(0)
> 
> I'm interested in the number that appears between the parentheses after
> the word CURDEPTH. This number will vary depending on the health of my
> application. I want to script something that says if this number is
> greater than 100, send an email to me.
> 
> For those who care, the number is the Queue Depth for the queue running on
> my MQ Series server. When this number is over 100, I want to be notified
> so that I can check on my application.
> 
> I can use: awk '{ print $2 ; }' curdepth.txt | sed -e 's/CURDEPTH(//' -e
> 's/)//' > number.txt to strip away all the text except for the number (and
> I'm sure there is a more elegant solution), but how do I assign this to a
> variable that I can compare to my threshold point?
> 
> Right now, I just want something functional and don't care about elegant.
> Any and all help is greatly appreciated!
> 
> Howard
> 
> **************************************************************
> * Then I realized that it is good and proper for a man to
> * eat and drink, and to find satisfaction in his toilsome
> * labor under the sun during the few days of life God has
> * given him - for this is his lot. Moreover, when God gives
> * any man wealth and possessions, and enables him to
> * enjoy them, to accept his lot and be happy in his work -
> * this is a gift of God. Ecclesiastes 5:18-19 NIV
> **************************************************************
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
> 
> 
> 
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
> 
> 


-- 
http://warrenmyers.com
"God may not play dice with the universe, but something strange is going on 
with the prime numbers." --Paul Erdos



More information about the TriLUG mailing list