4 Replies Latest reply on Feb 6, 2008 10:03 AM by gilburns

    Script exit codes?

    Apprentice

      I have a .sh file that I call from a LANDesk custom script:

       

      \[MACHINES_MACX\]

      REMEXEC01=/path/to/my/shell.sh, STATUS

       

      I want to provide an exit code that actually means something to LANDesk. Is there a place that this is documented? I have tried various numbers. Numbers other than exit 0 show different results when the status is reported, but it always show success. I want to provide a code that tells LANDesk that the script failed.

       

      Anybody know?

       

      Thanks!

        • 1. Re: Script exit codes?
          Jared Barneck SupportEmployee

          You can try to use this after the comma:

           

          FACILITY=

           

          Here are the ones I know about.

           

          Where ID is the facility for the failing application.  We only have facilities for somethings.

           

          Facility     Description

          0     Schedule plug in facility, the error codes will be loaded from the resources within the scheduler application

          3500     General software distribution failure

          3501     Failure at the SDCLIENT.EXE level

          3502     Failure in the code that installs MSI packages

          3503     Failure when installing an LSWD/generic executable

          3504     ESWD package failure

          3505     Facility code for core tech ping (CBA Ping) used in Custjob.

          3506     Facility code for DOS

          3507     Vulscan

          3510     Exit codes with this facility code originate from IMAGE.EXE

          3511     Exit codes with this facility code originate from Symantec* Ghost*

          3512     Exit codes with this facility code originate from PowerQuest* ImageCenter*

          4095     Facility code for ESWD package custom error codes.

          8191     Facility code for ESWD custom error codes where a reboot is required.

          7     Windows facility. When a facilities listed in the WINERROR.H header file is encountered the scheduler plug in will attempt to load the message from Windows

           

          This might sound funny, but you may want to try facility 7 (Windows errors).  Even though it is Windows, the error string rarely mentions windows and you can see all the error strings here:

          http://msdn2.microsoft.com/en-us/library/ms681381.aspx

           

          So you return an error 1 and you will get "Incorrect function".

           

          Numbers other than exit 0 show different results when the status is reported, but it always show success.

           

          Even knowing the information above, I am not sure that it will work for the reason you just stated.  I am not sure that the Custom SCript will even report a failure no matter what error number you return.  I know for linux that is the way it is.  Even you report an error 1, it still says success, though the custom script log result does show the 1 result, it doesn't know that the 1 result is a failure.

           

          Somehow that is customized and even if your command returns an error code (something other than 0), I am not sure that it will be seen as an error.

           

          You will probably have better luck putting this into a MAC Distribution package, which I believe does support shell scripts now...at least I think it does.

          • 2. Re: Script exit codes?
            Apprentice

            The FACILITY= is helpful, but you are right, it still reports as success every time the task is run. Though now, at least the Result message associated with the task reports something more meaningful.

             

            I really should be able to have it show the job as failed so LANDesk can attempt it again automatically according to a schedule that is specified on the task. I shouldn't have to go into the job, remove computers that succeeded (but really failed), and re-add the computers so I can try them again.

            • 3. Re: Script exit codes?
              Jared Barneck SupportEmployee

              I see your point.  I currently think they have so far done a pretty good job with error handling, though I can also see a lot of improvements that can be made to error handling.

               

              Did you try pushing the script as a Distribution Package though?  I could be wrong but I have been under the impression that LANDesk is moving away from Manage Scripts and it is not something LANDesk is really enhancing or improving.  They may never go away as they have some good uses, but they may not be a focus of development enhancements.

               

              The Distribution Package to deploy this shell script should work to return the error code you specify, though it will not allow you to choose the Facility.

              • 4. Re: Script exit codes?
                Apprentice

                Yes, pushing the script with a Distribution Package instead of using a LANDesk Custom Script seems to work. It looks like I can supply any non zero exit code in the script and it shows as failed in the Scheduled Task.

                 

                Thanks!