[TriLUG] OT - script help

Robert Ryals rryals at tmio.com
Fri Jul 8 14:06:59 EDT 2005


Howard Boyd wrote:

>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? 
>  
>
Enclose the entire command in back ticks and assign it to a variable

x=`awk '{ print $2 ; }' curdepth.txt | sed -e 's/CURDEPTH(//' -e's/)//'`




More information about the TriLUG mailing list