2

first time I've used blat and it appears to work fine however its sending two emails for every email I intend to send. Script excerpt is below:

::If we have a problem we email from here
CALL :checkForFailures

:checkForFailures
IF EXIST %ERROR_FILE% CALL :email & EXIT /B 1
::pause
GOTO :eof

:email
IF %TOLOG%==Y (
BLAT -f noreply@mydomain.com -to sapatos@mydomain.com -server myserver -subject "subject text" -body "Body text" -attacht 
::%PROBLEM_LIST% >> %LOGFILE%
) 

GOTO :eof

I've tried running this with and without output to the logfile. runs fine from the cmd prompt but just issues within this script.

Thanks for the help

ghostdog74
  • 327,991
  • 56
  • 259
  • 343
sapatos
  • 1,292
  • 3
  • 21
  • 44

2 Answers2

2

Maybe you should stop your batch file after your call to :checkForFailures:

::If we have a problem we email from here 
CALL :checkForFailures 
goto :eof

:checkForFailures
...

Otherwise you call it once, and execution continues directly after the call. In which case it runs the :checkForFailures subroutine again and sends out a second mail.

Joey
  • 344,408
  • 85
  • 689
  • 683
  • Perfect thanks. wasn't expecting the :checkForFailures to be run unless a CALL was made – sapatos Jan 10 '10 at 22:27
  • Sorry Joey only just found out how...or that you were even supposed to do so. – sapatos Sep 26 '10 at 23:18
  • You're not really supposed to. Some people here take the stance that people who don't should be beaten into submission until they do. I'm rather on the opposite side there. – Joey Sep 27 '10 at 09:28
0

how is the entire thing getting triggered? is it a file modify/create flag that's doing it? sometimes those kinds of triggers can be double counted because of the way the OS handles the modified/create triggers.

Keng
  • 52,011
  • 32
  • 81
  • 111