The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Include PERL script with in the unix shell script ganapati UNIX for Dummies Questions & Answers 1 04-29-2008 01:18 PM
Maintain full path of a script in a var when sourcing it from a different script mrbluegreen Shell Programming and Scripting 4 03-19-2008 10:31 PM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 03:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 04:06 AM
check in unix shell script so that no one is able to run the script manually adi_bang76 Shell Programming and Scripting 1 11-16-2006 10:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-19-2008
Gayathri22 Gayathri22 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
Need help in wwarning script very urgent

Hi

I have a file that contains some 24 key(encryption) id and their expiry date in the consequent lines
The pattern is as follows
Key ID:
Expires:

Now i need to write a script for warning the admins 2 months before the key expiry.

Please help...

Last edited by Gayathri22; 03-19-2008 at 04:48 AM..
  #2 (permalink)  
Old 03-19-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
This would get you going... Of course , please modify according to your needs...

Code:
# Arg_1 = [DAYS:-1]
{
    days=${1:-1}
    date_d=`date +%d`
    date_m=`date +%m`
    date_y=`date +%Y`
	#--------------------------------
	# Days Back Size Test
	#--------------------------------
	if [ $days -lt $date_d ]
	then
		date_d=`expr $date_d - $days`
	else
		days=`expr $days - $date_d`
		date_m=`expr $date_m - 1`
		month_length=`s_month_length $date_m`
		while [ $days -gt $month_length ]
		do
			days=`expr $days - month_length`
			date_m=`expr $date_m - 1`
			month_length=`s_month_length $date_m`
		done
		date_d=`expr $month_length - $days`
	fi
	#--------------------------------
	# Date	String Padding
	#--------------------------------
	if [ $date_d -lt 10 ]
	then
		date_d="0"$date_d
	fi
	if [ $date_m -lt 10 ]
	then
		date_m="0"$date_m
	fi
	echo $date_y $date_m $date_d
}

Last edited by Yogesh Sawant; 03-19-2008 at 04:01 AM.. Reason: added code tags
  #3 (permalink)  
Old 03-19-2008
Gayathri22 Gayathri22 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
thank you so much

i am not able to redirect the lines or strings from the file to the array so that i can retrieve the date field..please help
  #4 (permalink)  
Old 03-19-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
Please post your code, where you are getting error. Sorry but did not get your question.
  #5 (permalink)  
Old 03-19-2008
Gayathri22 Gayathri22 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
i have some 6 lines in the file of the pattern

1 Key Details: ADOBEB2B-IK-001 <info-security@adobe.com> Expires: 2008-03-14

ok.

Now i need to retrieve only the date and compare the date with the current date and send mails to the admins saying that the particular key is going to expire in 2months
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0