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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with Script

Status
Not open for further replies.

froggger

MIS
Apr 2, 2003
34
CA
Trying to write a script which will look at a demo license file on a system and when the expiration date is 5 days, 4-1 days and 0 days away send one of three different messages as an email notification to an external email address.

So far in my script script is able to look at the license file and grab the expiration date.

#! /bin/sh

vxlicense -p | grep "days from now" |awk '{print $ 10}'

...here I have a problem of the awk command grabbing a "(" character in front of my number so my output looks like (17.2

I would like to know if there is a way to awk just the numerical values and need code to compare the numerical value to 5, < than 5 & >0, and finally 0 or less. With each of these scenarios I will need to send one of three different email messages to an external email address.

This I believe I can accomplish using code that would look something like echo send this message | mailx -s text mailboss@this.com

please help me someone

 
Hi:

awk seems to be interpreting the 10th field of the vxlicense command as having the ( character in it. Have you considered something like this:

# untested
vxlicense -p | grep &quot;days from now&quot; |tr -d &quot;\(&quot;|awk '{print $ 10}'

Regards,

Ed

 
You could also do

Code:
vxlicense -p | grep &quot;days from now&quot; | awk '{print substr($10,2)}'

to trim the first character off of $10.

The man pages for &quot;awk&quot; are quite good for learning how to use it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top