4 Replies Latest reply on Dec 16, 2010 5:44 PM by CL

    Error handling from MAXL into a batch file

      Hello all
      I need to know how do we pass a value to a batch file from MAXL script if an error occurs.

      I have used the following in my MAXL to catch an error.
      login username password on server01;
      Iferror 'error';

      Define Label 'error';
      In the batch file I used:
      If %errorlevel% NEQ 0 goto catch

      echo an error occurred during MAXL script
      This doesnt give me any error even the login info is wrong in the MAXL script
      Please correct if this is wrong and provide any help if possible
      Thanks in advance
        • 1. Re: Error handling from MAXL into a batch file
          You might try

          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.
          1 person found this helpful
          • 2. Re: Error handling from MAXL into a batch file
            Here's the error checking code I used in my last not-DOS-but-we-call-it-that script:
            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)
            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.


            Cameron Lackpour
            1 person found this helpful
            • 3. Re: Error handling from MAXL into a batch file
              Hi GlenS,
              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.
              • 4. Re: Error handling from MAXL into a batch file
                The code I gave you works -- it was part of a framework code that ran many MaxL scripts.

                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


                Cameron Lackpour
                1 person found this helpful