Software License Expire in 30 days

I wrote code to read a file text with contents of expiration dates and products. The products expire in thirty days and each day an email message is send as a reminder of the number of days left before the license expires.

The code generates errors when executed .

Here is part of the code. Please see attachment:

# 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

foo5.txt : contents in foo5.txt are as follows:

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

it looks like you haven't scripted for shell before, read this guide to bash.

Wildly guessing and assuming a) your file is <TAB> delimited, b) your date version accepts the -d opton, c) you're using a decently recent shell, I imagine this could be of some help

TODAY=$(( $(date +"%s / 86400") ))
while IFS=$'\t' read SW EXP REST
  do DIFF=$(( $(date -d"$EXP" +"%s / 86400") - $TODAY ))
     [ $DIFF -gt 0 ] \  
         && printf "%s\n" "$DIFF days left for $SW etc."\
         || printf "%s\n" "$SW expired; grace period etc."
  done < foo5.txt