tags:

views:

159

answers:

2

Hi,

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 [email protected] -to [email protected] -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

+2  A: 

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
Perfect thanks. wasn't expecting the :checkForFailures to be run unless a CALL was made
sapatos
You can accept answers, you know?
Joey
Sorry Joey only just found out how...or that you were even supposed to do so.
sapatos
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
A: 

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