Sheel script to check for a specific file

June 16, 2009 at 03:41:50
Specs: Windows XP
Hi Friend,

We have a system which generates daily report in .xls format 5pm exactly for 20 customers.

Actually the report is generating in Unix system then it transfers to the Windows box.

After transferring to unix box The fine name format will be look like this day_CustName_LSR_YYYYMMDD.xml

LSR is the contant value and YYYYMMDD is the date of creation of file.Actually the yersterday report will get generate today. Mean to say if today is 03/06/2009,

we will have Wed_SBC_LSR_20090602.XML file.

The batch script should check whether the file is created for the date. If no it should send a alert mail SAY, aveen@xyz.com. Actually I am bit new to batch script file and I seen your posts. Could you please help on this.

Waiting for your reply.
Aveen


See More: Sheel script to check for a specific file

Report •


#1
June 16, 2009 at 04:59:25
here's an alternative solution , if you can download gawk for windows (see my sig ) and bmail (which is emailing command line tool)
BEGIN{
	server="smtp.server.com"
	to = "somewhere@email.com"
	from = "me@here.com"
	subject="error"
	t = strftime("%Y %m %d %a",systime())
 	split(t,timestamp," ")
	year=timestamp[1];mth=timestamp[2];day=timestamp[3];dday=timestamp[4]	
}
{
	split($0,f,"_")
	split(f[4],f4 ,".") 
	if ( f[1] == dday && f4[1] == year mth day ){		 
		 printf "OK"
	}else{
		cmd="bmail -s "server" -t "to" -f "from" -h -a "subject
		print cmd
		#system(cmd) #uncomment to use
	}
} 

save as myscript.awk and on command line
c:\test>dir /b *XML | gawk -f myscript.awk 

GNU win32 packages | Gawk


Report •

#2
June 16, 2009 at 05:12:38
Hi Thanks for your reply. Could yopu please help me more on this. I am new to batch file.

Actually first I need to check whther the file is created with todays date with the format I specified above. If it is exist well and good. no need to generate any message. If no it should send mail.

As we are running the script on office servers I can use any applications. If you provide me the scripts to check whether the file is present in specific format would be very helpfull..

Regards
Aveen
-


Report •

Related Solutions


Ask Question