![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi , How db2 return codes works into a windows batch file? I try to explain my needs: i want to write a batch file for -make offline backup of db2 (version 8.2,9.5) -check the backup image file with db2ckbkp utility -copy the backup image on a network drive with a simple copy command if an error occurred into any of these steps i want to send a message or write something on the screen (or send an email with the problem to a list of users) my problem is that i'm unable to check the return code of every command, it seems that errorlevel variable is not working. |
|
ps: for me is ok also to use other script languages available on windows, if this solve the problem. can you help me? JH |
#3
| |||
| |||
|
|
Try next bacth-file, and see that errorlevel is working just fine. @echo off del test.txt copy test.txt test.bak echo The value of ERRORLEVEL after a unsuccesfull copy: %ERRORLEVEL% dir >test.txt copy test.txt test.bak echo The value of ERRORLEVEL after a succesfull copy: %ERRORLEVEL% ps: for me is ok also to use other script languages available on windows, if this solve the problem. can you help me? JH If you dont know how to write a simple batchfile, than ... i wont be able to help sorry... |
#4
| |||
| |||
|
|
now: try to add a "db2 backup db xxxx........" in the same batch file and to test the errorlevel variable when the backup fails, and tell me if its working. In my environment (win xp-pro + db2 express-c 9.5) the errorlevel variable is not working for db2 commands... |
#5
| |||
| |||
|
|
On Aug 25, 11:04 am, John Hopfield<Hopfi... (AT) freemail (DOT) it> wrote: now: try to add a "db2 backup db xxxx........" in the same batch file and to test the errorlevel variable when the backup fails, and tell me if its working. In my environment (win xp-pro + db2 express-c 9.5) the errorlevel variable is not working for db2 commands... Not sure why it does not work for you. db2.exe, the DB2 command line processor, returns 4 for errors, 2 for warning, and 0 for successful commands. D:\>cat test\t.cmd db2 backup db nonexistent to c:\temp echo %errorlevel% if errorlevel 4 echo errorlevel 4& goto :eof if errorlevel 2 echo errorlevel 2& goto :eof if errorlevel 1 echo errorlevel 1& goto :eof echo no error D:\>test\t.cmd D:\>db2 backup db nonexistent to c:\temp SQL0104N An unexpected token "nonexistent" was found following "DB". Expected tokens may include: "<database-alias>". SQLSTATE=42601 D:\>echo 4 4 D:\>if errorlevel 4 echo errorlevel 4& goto :eof errorlevel 4 |
![]() |
| Thread Tools | |
| Display Modes | |
| |