Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-11-01 : 10:37:44
|
Hello,I am trying to get a mail , when a bat file fails execution. I have the following:osql -E -id:\SqlServerrefresh\refresh\usersinfo.sql -od:\SqlServerrefresh\refresh\outputfileD.txtfindstr "Msg 170" outputfileD.txtblat messageFile.txt -to addressIf the bat fails , it gives me the mail, but if the bat DOES not fail, I should not get any mail...how can I do this.Thanks |
|
X002548
Not Just a Number
15586 Posts |
|
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-11-01 : 10:58:32
|
I have the whole thing in one bat file.Like the osql command and the following commands in one bat file.If I remove the line : if errorlevel=0 , it gives me a mail , even if the bat fails or succeeds.Thanks |
 |
|
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-11-01 : 11:37:10
|
Got the thing working.sql -E -id:\SqlServerrefresh\refresh\usersinfo.sql -od:\SqlServerrefresh\refresh\outputfileD.txtfindstr "Msg 170" outputfileD.txtrem (execute a program which returns an errorlevel of 0 or 1) if errorlevel 1 goto ONE if errorlevel 0 goto ZERO goto END :ONE echo a Zero was returned! goto END :ZERO blat messageFile.txt -to test@test.com :END |
 |
|
|
|
|