Software License Expire in 30 days


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Software License Expire in 30 days
# 1  
Old 09-06-2015
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:

Code:
# 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:


Code:
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


Last edited by Don Cragun; 09-06-2015 at 08:00 PM.. Reason: ADD CODE tags again!
# 2  
Old 09-06-2015
it looks like you haven't scripted for shell before, read this guide to bash.
# 3  
Old 09-07-2015
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
Code:
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

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expire license

I have a program that outputs a file on the number days left before software license expired. It reads in a text file name expiredt.txt. expiredt.txt contents are as follows: EM software 30NOV2015 11/30/2015 ABM software 30NOV2015 11/30/2015 ABM software ... (2 Replies)
Discussion started by: dellanicholson
2 Replies

2. Shell Programming and Scripting

Updating the license tag in XML file with new license

Hi All, I have a XML file : System.xml in which I want to update the license tag with the new data from file licence.xml. The content of files is in following format: System.xml: <?xml version="1.0"?> <!DOCTYPE Configuration SYSTEM "SystemVariables.dtd"> <usageConfiguration... (2 Replies)
Discussion started by: Pramod_T
2 Replies

3. Solaris

user to be never expire ..

Hi All, I have Solaris 9 and there is user created in that server called appuser That user should to be never expire.. can anyone advice me how can I modify that user to be never expire thru the command line without using GUI tool. (1 Reply)
Discussion started by: Mr.AIX
1 Replies

4. Solaris

Change hostid for software install - license issue

Hi all. Solaris 9. After I change the hostid, how can I change it back without rebooting the machine? Thanks (2 Replies)
Discussion started by: jamie_collins
2 Replies

5. Shell Programming and Scripting

Expire Command | Need Help

Hi , I am trying to execute the ipl file as below : my $user="iwadmin"; chomp $user; system("passwd -x 29 $user"); The ipl file executes with out any issues when i have logged in as root in solaris .but when when i try to execute the same file with other user id ie iwadmin ,it says... (3 Replies)
Discussion started by: abhishek1979
3 Replies

6. HP-UX

license of software package

Hi when i do a swlist on my HP-UX machine it displays the software packages ..How do i know whether those packages are licensed or freeware can any 1 help me best Regards vasanth (0 Replies)
Discussion started by: vasanthan
0 Replies

7. Solaris

Set Password Never Expire

Hello I want to set the password for user never expire through the command line. For your information the box is running under Solaris 8 platform. (2 Replies)
Discussion started by: shamsul
2 Replies

8. Shell Programming and Scripting

Password expire

Hi, Is there any way to find out the UNIX user's password expire date?. It'll we helpful to inform the users to change the password before it get expires.(FYI - I am not having only admin previlege.) (1 Reply)
Discussion started by: sharif
1 Replies

9. UNIX for Advanced & Expert Users

password will expire

login: TEST7 TEST7's Password: Your password will expire: Wed Feb 19 14:28:08 2003 How can I the same information become in a script (as example in the .profile)????????? My login starts with .profile. These File is a menue with 24 lines and the message " Your password ....." disappear to... (8 Replies)
Discussion started by: Erwin Stocker
8 Replies
Login or Register to Ask a Question