ESP Workload Automation

 View Only
  • 1.  How to check for negative return codes from a Windows program

    Posted Dec 07, 2015 08:34 PM

    I have ESP workload running a Windows program which is returning a negative return code when it ends.  Even ending normally it is always a negative value.  ESP is seeing this as FAIL.  How can tell ESP that this return code is SUCCESS.  EXITCODE statement does not allow negative numbers.



  • 2.  Re: How to check for negative return codes from a Windows program
    Best Answer

    Posted Dec 08, 2015 01:24 AM

    One option would be to use a .bat or powershell wrapper around your command to capture the negative return code and return a more appropriate exit code.

    Here is an example Powershell script:

     

    Invoke-Command {ping -n 1 foo}

     

    switch ($LASTEXITCODE)

    {

      1 {echo "Program returned 1";[Environment]::Exit(3)}

      default {echo "Program returned undefined exit code"}

    }

     

    In the above example, the ping command is called via the powershell script. The ping command returns 1 after it fails to ping "foo". The powershell script in turn returns an exit code of 3 instead.

    Here is example output:

     

    C:\src>powershell ./test.ps1

    Ping request could not find host foo. Please check the name and try again.

    Program returned 1

     

    C:\src>echo %errorlevel%

    3

     

     

    You can of course modify this to fit your needs.