The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Selecting a line value unibboy Shell Programming and Scripting 4 02-12-2008 02:41 PM
tar - Selecting target dir GNMIKE UNIX for Dummies Questions & Answers 3 11-05-2005 03:52 AM
selecting each paragraph and put it into a file...help me swamymns Shell Programming and Scripting 2 10-04-2005 08:46 AM
Selecting information from several web pages... Vishnu UNIX for Dummies Questions & Answers 2 11-06-2002 02:04 PM
Selecting unknown string. Cameron UNIX for Dummies Questions & Answers 2 12-18-2001 12:48 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 12-30-2003
Registered User
 

Join Date: Dec 2003
Posts: 17

Problem - ive just noticed ive written the date format wrongly - does this make a difference?

I should have written
200307072003070420030707

This is the format that the script will have to read. Can i change the script to yyyymmdd????


This is the format it will always take i.e with the 01, 02 ....

On the script you said would work does the data_file refer to the path name where this file is held. Do i replace data_file with the pathname?

Thanks
Forum Sponsor
  #9  
Old 12-30-2003
Registered User
 

Join Date: Dec 2003
Location: India
Posts: 50
You could very well change the sequence, just read the man page for *date*, it has more informations

date -u +%Y%m%d

data_file is the file in which you have your sequence of dates ie

20030707.........................

Regards
JK
  #10  
Old 12-30-2003
Registered User
 

Join Date: Dec 2003
Posts: 17


Forgive me but ive never actually created a script
if i login to unix session and enter the script as it is

#!/bin/ksh
FILE_DATE=$(cut -c 9-15 ../../../data_file | head -1)
TODAYS_DATE=$(date +'%Y%m%d)

if [ ${FILE_DATE} != ${TODAYS_DATE} ]
then
echo "Dates Dont Match"
fi

then this will work. (Idont have to enter anything else?)
Do i just save it and then call it up with autosys?

Thanks - in advance
  #11  
Old 12-30-2003
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Yes, this should work, but you should use a full path to the file name. I dont usually use relative paths. Also, if your date file only has 1 line in it then you can remove the | head -1 as this simply makes sure that the only 1 row is returned. Before adding it to the autosys queue, I would test it by running it! Make sure to give it executable permissions (chmod command).
By the way, data_file represents your file name. Change this to the name you call your file.

Also, this is very simple script, you may want to add some things to it such as a log file. The echo command "Dates dont match" will echo to standard out and will most certainly be missed by everyone. Redirect the output to a file, or have the script mail you a message if the dates do not match. There are many examples of mail scripts on these boards. Search them out. Good Luck
  #12  
Old 12-30-2003
Registered User
 

Join Date: Dec 2003
Posts: 17
Smile

Thanks for your help

I dont know about the chmod but i'l look it u in man n give it a go.

Thanks!
  #13  
Old 12-30-2003
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
this program assumes the following:
1) the pattern you are looking for is 8 charicters from the beginning of the line.

provided that condition is met this does what you need.

1) open a text editor and past the below code in it.
2) save the file and exit the editor
3) chmod 755 file_you_just_made
4) to execute the file type "./file_you_just_made FILE_TO_SEARCH DATE_TO_MATCH

5) if the date is NOT found you get an error on your screen
5a) if date IS found it exits quietly

Code:
#!/usr/bin/perl -w
#200307072003070420030707

use strict;

if ($#ARGV != 1) { print "Usage: ./script file_to_search date_to_search\n"; exit };
my $file=shift;
my $date=shift;

open (FILE, "$file") or die "Can not open the file ($!)";
my @data=<FILE>;
print "ERROR No proper date found\n" if (! grep /^........$date/, @data) ;
  #14  
Old 01-09-2004
Registered User
 

Join Date: Dec 2003
Posts: 17
Unhappy

Hi there!!

Since discovered that this file has more than one line that it has to check!!

The format of the file looks like

MP 000000000000000000000000 200307072003070420030707000000000000000000
00000000.000000000000000.0000000000000000000000000000000000000000

MP 0000000000000000000000000 200307072003082920030707000000000000000000
00000000.000000000000000.0000000000000000000000000000000000000000

MP 000000000000000000000000 200305212003121720030521000000000000000000
00000000.00000000000000000000000000000000000000000000000000000000

There are somethin in the region of 9 of these sets of lines in a file. All of which should have the ssame date.
Didnt get the chance to try the first set of solutions unfortunatley so really not sure n how i would manage to get this to work.

Is it possible??
Can anyone help please??

To recap ive to get a script to check this file in particular the 200305212003121720030521 and to check the middle date in this = todays date and if not then raise an alert (which already exists so im assuming i just put in a pathname to the script)

Thanks in advance.

Last edited by vcardo10; 01-12-2004 at 02:56 AM.
Google The UNIX and Linux Forums
Closed Thread

Tags
autosys

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0