Link to home
Start Free TrialLog in
Avatar of dfn48
dfn48

asked on

SAS License expire in 30 days .

When I execute my shell script program, it errors.  The program calculate the number of days left before licenses expire which the target is 30 days between the  current date and the expiration date. The program send email with the number days left and the product names.





# Convert date to check in seconds 
current_date='date "+%s"'

#foo5.txt 

expires=' /path/to/ foo5.txt
-noout -enddate | grep | awk '{print $1, $2, $3}''

date_to_check=date -d  | awk -v expires="$expires" '{print $2 expires}'expires "+%s"'

#calculate the datediff
datediff='expr $date_to_check - $current_date'


#30 days left - send email: 30 days in seconds(2592000)

if [ 'expr $date_diff - 2592000' -gt 0 ]
then 
echo | awk expires="$expires"'{print "30 days left. Product and Expiration date: " $1, $3 }'expires'| mail -s "Product Expiring" mary@rer.com

# 29 days left - send email- 29 days in seconds(2505600)

elif [ 'expr $date_diff - 2505600' -gt 0 ]
then
echo | awk expires="$expires"'{print "29 days left. Product and Expiration date: " $1, $3}'expires'| mail -s "Product Expiring" mary@rer.com

# 28 days left send email. 28 days in seconds(2419200) 

elif [ 'expr $date_diff - 2419200' -gt 0 ]
then 
echo | awk expires="$expires"'{print "28 days left. Product and Expiration date:"  $1, $3}'expires'| mail -s "Product Expiring" mary@rer.com

# 27 days left -  send email 27 days in seconds (233200)

elif [ 'expr $date_diff - 233200' -gt 0 ]
then 
echo | awk expires="$expires"'{print "27 days left. Product and Expiration date:" $1, $3}'expires'| mail -s "Product Expiring" mary@rer.com
fi

Open in new window


Text file: foo5.txt:

B colb software    2015/11/30           30Nov2015
S/G                         2015/10/30           30Oct2015
GH/Software        2015/11/30           30Nov2015
KP/software         2015/10/30            30Oct2015
license-expires-in-30-days.txt
foo5.txt
ASKER CERTIFIED SOLUTION
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial