scobb13
asked on
Batch Script email on success or failure
I'm stuck trying to get the script below to send the email on success or failure. It works otherwise. When the script runs it throws the following error for the send mail portion only. Any help with this would be appreciated.
Error:
0 1242930762 2 0 0 4556 4972 0 backupserver.domain.net smtpmail 2 %s 1 0 48 protocol failure; got 501 5.5.4 Invalid Address
Script:
rem @echo off
REM This script should be run on the Networker server.
setlocal
set MAILSERVER=server.domain.n et
set RECIEPENTS=user@domain.com
set SERVER=backupserver.domain .net
set DESTPOOL="Backup Clone"
set DAILY1="Daily Backup Clone"
set LOG=daily_clone.log
echo Cloning started at %DATE% %TIME% >> %LOG%
nsrclone -b %DESTPOOL% -s %SERVER% -y month -w month -S -g %DAILY1% -e now -C 1 >> %LOG% 2>&1
if %ERRORLEVEL% GTR 0 (
echo ERROR: Cloning of %DAILY1% terminated with errors %DATE% %TIME% >> %LOG%
smtpmail -h %MAILSERVER% -s "ERROR: Cloning of %DAILY1% terminated with errors" -f Networker %RECIEPENTS% < %LOG%
) else (
smtpmail -h %MAILSERVER% -s "Cloning of %DAILY1% Completed Succesfully" -f "Networker" %RECIEPENTS%
)
:end
del %LOG%.09
move %LOG%.08 %LOG%.09
move %LOG%.07 %LOG%.08
move %LOG%.06 %LOG%.07
move %LOG%.05 %LOG%.06
move %LOG%.04 %LOG%.05
move %LOG%.03 %LOG%.04
move %LOG%.02 %LOG%.03
move %LOG%.01 %LOG%.02
move %LOG%.00 %LOG%.01
move %LOG% %LOG%.00
endlocal
Error:
0 1242930762 2 0 0 4556 4972 0 backupserver.domain.net smtpmail 2 %s 1 0 48 protocol failure; got 501 5.5.4 Invalid Address
Script:
rem @echo off
REM This script should be run on the Networker server.
setlocal
set MAILSERVER=server.domain.n
set RECIEPENTS=user@domain.com
set SERVER=backupserver.domain
set DESTPOOL="Backup Clone"
set DAILY1="Daily Backup Clone"
set LOG=daily_clone.log
echo Cloning started at %DATE% %TIME% >> %LOG%
nsrclone -b %DESTPOOL% -s %SERVER% -y month -w month -S -g %DAILY1% -e now -C 1 >> %LOG% 2>&1
if %ERRORLEVEL% GTR 0 (
echo ERROR: Cloning of %DAILY1% terminated with errors %DATE% %TIME% >> %LOG%
smtpmail -h %MAILSERVER% -s "ERROR: Cloning of %DAILY1% terminated with errors" -f Networker %RECIEPENTS% < %LOG%
) else (
smtpmail -h %MAILSERVER% -s "Cloning of %DAILY1% Completed Succesfully" -f "Networker" %RECIEPENTS%
)
:end
del %LOG%.09
move %LOG%.08 %LOG%.09
move %LOG%.07 %LOG%.08
move %LOG%.06 %LOG%.07
move %LOG%.05 %LOG%.06
move %LOG%.04 %LOG%.05
move %LOG%.03 %LOG%.04
move %LOG%.02 %LOG%.03
move %LOG%.01 %LOG%.02
move %LOG%.00 %LOG%.01
move %LOG% %LOG%.00
endlocal
It would seem that your feeding it an invalid recipient. Have you run the mail command outside the script? Or considered using BLAT instead (I'm not familiar with SMTPMAIL.
ASKER
Yes. It works if it is run outside the script.
And since you've commented out echo off, what does the line display when it runs in the script? Copy and paste it to another window and run it from there.
ASKER
Does the same thing. I think it may have something to do with the " around the "DAILY1" variable.
you put quotes around "networker" in the second smtpmail (success) call, but not the first (failure) call?
ASKER
Quotes around networker didn't change anything. I'm pretty sure it's the quotes pulling to the variables into the mail subject.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.