This content has been marked as final. Show 4 replies
You might try1 person found this helpful
using Exit 1; if there is an error and Exit 0; if there is not. Use labels or gotos's and iferror statements to get to the correct exit statement.
Here's the error checking code I used in my last not-DOS-but-we-call-it-that script:1 person found this helpful
The 2>&1 command at the end of the MaxL script line merges STDOUT and STDERR into an overall log file I used for other processes as well as MaxL. It's great for that purpose, but unfortunately logs the username and password -- this would be overcome by encrypting those values. It was acceptable for the solution so I didn't lose any sleep over it.
REM Call MaxL script with parameters REM The 2>&1 at the end of the below line merges CMD's STDERR into STDOUT %hyperion_home%\products\essbase\essbaseclient\bin\essmsh.exe %batAutomation%\%esbAppName%\MaxL\%mshScriptName%.msh %esbUsername% %esbPassword% %esbServer% %esbAppName% %mshScriptName% %batDrive% %batAutomation% >>%log% 2>&1 REM Test for MaxL execution errors IF NOT %ERRORLEVEL% == 0 (SET errormsg=Error! - MaxL script %mshScriptName%.msh failed with ERRORLEVEL %ERRORLEVEL% & GOTO ERROR)
Thanks for the reply.
I tried with Exit 1 and Exit 0 codes. But the problem is how does the calling batch file know that there was an error? Is there a way to let the batch file know that the MAXL exit with an error?
To my knowledge, there is only one way of error handling in a batch command which is checking Errorlevel. In my case it only shows 0 value i-e no error occurred.
Please give me a code if you have any idea.
The code I gave you works -- it was part of a framework code that ran many MaxL scripts.1 person found this helpful
Alternatively, you could put something like this into your MaxL:
spool stderr on to 'c:\tempdir\odtug_2009\SpoolMe.err' ;
When you have an error, the file will exist.
You could then check for the existence of the file in your DOS script, like this:
REM If SpoolMe.err does exist, error
IF EXIST SpoolMe.err (SET errormsg=Error! - SpoolMe.msh ran with errors & GOTO ERROR)
I gave a presentation on MaxL automation two years ago at Kaleidoscope that covers this very topic. If you go to www.odtug.com, Technical Resources, and search for MaxL, you'll find it. There's source code there in the presentation. If you really, really care, you can go to my blog and download that presentation's real source code here: http://camerons-blog-for-essbase-hackers.blogspot.com/2009_07_01_archive.html