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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Help with FINDSTR

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.txt

findstr "Msg 170" outputfileD.txt

blat messageFile.txt -to address

If 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

Posted - 2006-11-01 : 10:46:52
The bat file did not "fail", it completes as successful even if the syntax inside that bat is bad



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

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
Go to Top of Page

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.txt

findstr "Msg 170" outputfileD.txt

rem (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
Go to Top of Page
   

- Advertisement -