ESP Workload Automation

 View Only
Expand all | Collapse all

Job showed CC=0 Success when it should have failed

  • 1.  Job showed CC=0 Success when it should have failed

    Posted Feb 06, 2024 10:34 AM

    Hello, we recently had an issue with a job trying to reach a network location. This job should have triggered a failure however the job showed CC=0 and completed successfully in ESP. I have reviewed the setup and can't see anything different from other jobs we have setup this way to execute bat files. Could someone help me to understand why the job did not fail even though there was an error connecting to a network location? Below you will see the spool files for the job in question. First one is from the day that should have showed a failure and the second is from a normal successful run.

    Daily should have failed

    ----------------------------------------------------------------

    Output of messages for workload object OSPMICR1/PRODMAIN.6104/MAIN

    Start date Thu Feb 01 10:48:51 2024

    ----------------------------------------------------------------

     D:\Program Files\CA\WA Agent>REM OSPMICR1.bat

     D:\Program Files\CA\WA Agent>REM @echo off

     D:\Program Files\CA\WA Agent>net use J: "\\gmcc.grange.local\Y\GRP2\Business Intelligence\MicroStrategy Output\S3Bucket\Upload\DBDoneFiles"

     System error 1232 has occurred.

     The network location cannot be reached. For information about network troubleshooting, see Windows Help.

     D:\Program Files\CA\WA Agent>cd /d J: 

     The system cannot find the drive specified.

     D:\Program Files\CA\WA Agent>type nul  1>DailyDataHubDone.txt

     D:\Program Files\CA\WA Agent>REM Set Error Level in ESP

     D:\Program Files\CA\WA Agent>"D:\Program Files\CA\WA Agent\SetExitC" ERRORLEVEL

     ----------------------------------------------------------------
     Output of messages for workload object OSPMICR1/PRODMAIN.6109/MAIN
     Start date Tue Feb 06 06:09:29 2024
     ----------------------------------------------------------------
     D:\Program Files\CA\WA Agent>REM OSPMICR1.bat  
     D:\Program Files\CA\WA Agent>REM @echo off  
     D:\Program Files\CA\WA Agent>net use J: "\\gmcc.grange.local\Y\GRP2\Business Intelligence\MicroStrategy Output\S3Bucket\Upload\DBDoneFiles" 
     The command completed successfully.
     D:\Program Files\CA\WA Agent>cd /d J: 
     J:\>type nul  1>DailyDataHubDone.txt  
     J:\>REM Set Error Level in ESP  
     J:\>"D:\Program Files\CA\WA Agent\SetExitC" ERRORLEVEL 
     



    ------------------------------
    [Keith Grizzell]
    [ESP Scheduler]
    [Grange Insurance]
    [Columbus] [Ohio]
    ------------------------------


  • 2.  RE: Job showed CC=0 Success when it should have failed

    Posted Feb 06, 2024 10:58 AM
    Edited by Rick Romanowski Feb 06, 2024 11:00 AM

    When your batch file exits it exits with the latest value of ERRORLEVEL

    If you update the batch file to check command status after attempting to connect to the network, you can save the result.

    Then at the end of the script use the variable ExitStatus

    Batch File Excerpt:

    net use J: "\\gmcc.grange.local\Y\GRP2\Business Intelligence\MicroStrategy
    if %errorlevel% NEQ 0 set ExitStatus=%ERRORLEVEL%

    .

    .

    .

    SetExitC" %ExitStatus%


    To verify, run from a command prompt when the batch completes type:


    echo %ERRORLEVEL%


     



    ------------------------------
    Rick Romanowski
    rromanowski@ups.com
    Sr. Systems Analyst
    UPS
    NJ, USA
    ------------------------------



  • 3.  RE: Job showed CC=0 Success when it should have failed

    Posted Feb 08, 2024 11:26 AM

    Thank you Rick! That worked just as you suggested. Thanks for the help



    ------------------------------
    [Keith Grizzell]
    [ESP Scheduler]
    [Grange Insurance]
    [Columbus] [Ohio]
    ------------------------------



  • 4.  RE: Job showed CC=0 Success when it should have failed

    Posted Oct 07, 2024 10:53 AM

    Hi Rick, we worked on this back in February and I thought I had it figured out. Turns out I was just lucky we didn't get the connection error until this past Friday so I thought it was working. Can you confirm the suggested edits to the bat file below? Bold in proposed is what I am looking to confirm

    ************* Original Daily Bat File *****************
    REM OSPMICR1.bat
    REM @echo off

    net use J: "\\gmcc.grange.local\Y\GRP2\Business Intelligence\MicroStrategy Output\S3Bucket\Upload\DBDoneFiles"
    cd /d J:
    type nul >DailyDataHubDone.txt

    REM Set Error Level in ESP
    :DONE
    "%ESPAGENTDIR%\SetExitC" %ERRORLEVEL

    ************ Proposed new daily bat file **********************
    REM OSPMICR1.bat
    REM @echo off

    net use J: "\\gmcc.grange.local\Y\GRP2\Business Intelligence\MicroStrategy Output\S3Bucket\Upload\DBDoneFiles"
    cd /d J:
    if %errorlevel% NEQ 0 set ExitStatus=%ERRORLEVEL%
    type nul >DailyDataHubDone.txt

    REM Set Error Level in ESP
    :DONE
    "%ESPAGENTDIR%\SetExitC" %ExitStatus%



    ------------------------------
    [Keith Grizzell]
    [ESP Scheduler]
    [Grange Insurance]
    [Columbus] [Ohio]
    ------------------------------



  • 5.  RE: Job showed CC=0 Success when it should have failed

    Broadcom Employee
    Posted Oct 08, 2024 02:26 PM

    Hi Keith,

    Rick has happily retired!

    I consulted our Windows experts and he thinks it should be fine and suggested that you enable REM ON to double confirm.

    Hope this helps,

    Lucy




  • 6.  RE: Job showed CC=0 Success when it should have failed

    Posted Oct 09, 2024 10:37 AM

    Lucy is correct that Rick has retired, but Broadcom has allowed me to still have access to Broadcom Communities.    :)

    I tested the Updated Bat file on a Windows PC and when I run it the NET USE command fails since I have no access to what is specified in the command.

    Test Bat File
    @echo off
    net use J: "\\gmcc.grange.local\Y\GRP2\Business Intelligence\MicroStrategy Output\S3Bucket\Upload\DBDoneFiles"
    cd /d J:
    if %errorlevel% NEQ 0 set ExitStatus=%ERRORLEVEL%

    echo type nul >DailyDataHubDone.txt
    echo Exitstatus:%ExitStatus%
    REM Set Error Level in ESP
    :DONE
    Exit /B %ExitStatus%

    Instead on commenting out @ECHO OFF, I added a ECHO statement to display the value of variable ExitStatus.


    I replaced the Broadcom SetExitC with the Windows native EXIT command (Windows system has no ESP Agent)


    After running the Bat File, the ERRORLEVEL is checked in the Command Window:

    Test.bat
    System error 53 has occurred.

    The network path was not found.

    The system cannot find the drive specified.
    Exitstatus:1

    echo %errorlevel%
    1


    My suggestion is for you to run this on your Test/Dev system and update the NET USE statement with incorrect information to cause the NET USE command to fail, this will allow you to test that the code functions as you need.




  • 7.  RE: Job showed CC=0 Success when it should have failed

    Broadcom Employee
    Posted Oct 10, 2024 09:40 AM

    Hi Rick,

    Thank you for your valuable input as always!

    Lucy




  • 8.  RE: Job showed CC=0 Success when it should have failed

    Posted Oct 09, 2024 12:24 PM

    Rick has happily retired, but Broadcom has allowed me access to the communities!

    I noticed one difference in the location of the "if errorlevel", I had it after the "net use", you have it after the "cd", that should not matter as both commands will still fail.

    Instead of using "echo on", I just added echo statements to provide visibility to what I needed to see.

    The Windows device I tested on does not have an ESP Agent so I replaced SetExitC with the native Windows command "exit".

    The /B option is used to exit from the batch file but not the Windows Command prompt.

    Test.Bat

    @echo off
    net use J: "\\gmcc.grange.local\Y\GRP2\Business Intelligence\MicroStrategy Output\S3Bucket\Upload\DBDoneFiles"
    cd /d J:
    if %errorlevel% NEQ 0 set ExitStatus=%ERRORLEVEL%


    echo Exitstatus:%ExitStatus%
    REM Set Error Level in ESP
    :DONE
    Exit /B %ExitStatus%

    Script run from Windows Command prompt

    >Test.bat
    System error 53 has occurred.

    The network path was not found.

    The system cannot find the drive specified.
    Exitstatus:1

    t>echo %errorlevel%
    1

    I suggest testing this is your development environment with an updated "net use" statement to cause it to fail. 

    I added "XYZ" to create the issue of the command failing.

    net use J: "\\XYZgmcc.grange.local\Y\GRP2\Business Intelligence\MicroStrategy Output\S3Bucket\Upload\DBDoneFiles"

    Test is a Windows Command window fist, than in ESP.

    Let me know if you have any questions.




  • 9.  RE: Job showed CC=0 Success when it should have failed

    Broadcom Employee
    Posted Feb 07, 2024 03:13 AM

    I agree with Rick,
    In Windows, %ERRORLEVEL is reset after each command that is executed

    The fact that the NET USE command and the subsequent "cd" command had problems does not prevent the "type" command from executing.  You will need to separately detect that the NET USE command has failed and exit the script be fore even trying to do anything else.

    What will be happening in the example of your "failed" job is that the file will be created in "D:\Program Files\CA\WA Agent" - and this will succeed, hence %ERRORLEVEL being 0



    ------------------------------
    Thanks in advance
    Chris
    ------------------------------



  • 10.  RE: Job showed CC=0 Success when it should have failed

    Posted Feb 08, 2024 11:28 AM

    Thanks Chris! Your explanation helped me understand what was wrong with my original bat file



    ------------------------------
    [Keith Grizzell]
    [ESP Scheduler]
    [Grange Insurance]
    [Columbus] [Ohio]
    ------------------------------