Home / Microsoft / Microsoft DOS / Batch file to send email notification
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Batch file to send email notification  (Read 1109 times)
ramWin
Topic Starter
Starter



Posts: 3


« on: June 15, 2009, 07:23:55 PM »

I need to create a batch file that runs every half hour or 1 hour on specific file (log file) and if it sees same timestamp on more than 20 lines it should send email notification. We have smtp service installed on the server. Appreciate if anybody help on this...

for example, timestamp shows something like this in the log file:

[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O MY_PROTO is
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O PLATFORM is qa
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O MY_HOST is abc.ac.tx.anet
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O MY_PORT is 389
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O MY_USER is
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O MY_PASS is avcfE
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O MY_PROTO is ldap://
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O PLATFORM is prod
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O MY_HOST is abc.ac.tx.anet
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut     O MY_PORT is 389

IP logged
gh0std0g74
Apprentice



Thanked: 37
Posts: 590


« Reply #1 on: June 15, 2009, 07:47:46 PM »

download blat (for sending email) and gawk for windows
Code: [Select]
{
 timestamp[$1,$2,$3]++
 }
END{
  for ( i in timestamp){
if (timestamp[i] >= 20) {
print "timestamp more than 20: ",i > "newfile.txt"
}
}
}
save the above as myscript.awk and on command line
Code: [Select]
c:\test> gawk.exe -f myscript.awk
c:\test> blat newfile.txt -to somewhere@some.com
IP logged

ramWin
Topic Starter
Starter



Posts: 3


« Reply #2 on: June 16, 2009, 11:28:42 AM »

Thanks for the quick response.
can you please send me the batch file that i need to scheduled on Windows server?
IP logged
ramWin
Topic Starter
Starter



Posts: 3


« Reply #3 on: July 13, 2009, 09:50:07 AM »

Where can i specify the name of the log file in the code you sent?
IP logged
Pages: [1] - (Top) Print 
Home / Microsoft / Microsoft DOS / Batch file to send email notification « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.124 seconds with 20 queries.