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, Actually I am bit new to batch script file and I seen your posts. Could you please help on this.

Waiting for your reply.

See More: Sheel script to check for a specific file

Report •

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)
	to = ""
	from = ""
	t = strftime("%Y %m %d %a",systime())
 	split(t,timestamp," ")
	split(f[4],f4 ,".") 
	if ( f[1] == dday && f4[1] == year mth day ){		 
		 printf "OK"
		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 •

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..


Report •

Related Solutions

Ask Question