Ignore Script Error so Policy Reports Back Completed

rwp16
New Contributor

We are running a script to install software. The installation completes on the computer, licenses via our license server and functions as it should. However the button remains in Self Service and it reports a failure. Since the process actually works, I would like to somehow ignore the error so that jamf thinks it completed successfully. Any ideas? Thanks in advance. - Rusty

Script result: + /private/tmp/SPSS_Statistics_Installer.bin
Preparing to install...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...

Launching installer...

Unable to find authenticator properties

Error running script: return code was 208.

11 REPLIES 11

leslie
Contributor II

You might try having another script call the install script and capture the result, then use a case statement to handle different results:

#!/bin/bash
install_result=$(/path/to/SPSS_installer_script;echo $?)

## might need to modify $install_result to get just the return code.

case $install_result in
    0|208)
        echo "successfully installed."
        exit 0
        ;;
    *)
        echo "failed to install."
        exit 1
        ;;
esac

You'll have issues of course if the 208 error is also thrown for some case where SPSS doesn't install properly.

seann
Contributor

I'm not sure if it's still the case but Jamf policy failures used to occur with more than just exit codes. The framework would actually check for certain strings in output such as 'error' or 'failure'.

There are a bunch of threads outlining how to possibly bypass false policy failures. Off the top of my head perhaps redirecting all output to /dev/null would help?

mm2270
Legendary Contributor II

Personally I think any attempts to circumvent the error is just band-aiding the issue. You should try to find out what's causing the error. As shown in your policy output, something in that script is erroring, but it's unclear why since there isn't much to go on. Maybe contact the vendor to see if they can assist. I'm willing to bet that there is something in the script attempting to run as the logged in user, but it can't do that when it's being installed under the root account as it would when run from a Jamf policy. It's not like we haven't seen vendor packages/scripts make assumptions about who and how the installer is being run and running afoul of management products like Jamf Pro.

If you are able to post the install script being used here, maybe we can help pinpoint where the issue is.

rwp16
New Contributor

Here is the full script. The error is occurring during the silent install of SPSS. If I run the install via terminal I get the same error. Thanks for the feed back so far, everyone. - Rusty

#!/bin/sh

# Set script to give better error messaging
set -eux

/private/tmp/SPSS_Statistics_Installer.bin -f /private/tmp/installer25ConCurrentL2CLS.properties

touch /Applications/IBM/SPSS/Statistics/25/SPSSStatistics.app/Contents/LicenseConCurrentL2CLS.txt

rm /Applications/IBM/SPSS/Statistics/25/SPSSStatistics.app/Contents/bin/spssprod.inf
mv /private/tmp/spssprod.inf /Applications/IBM/SPSS/Statistics/25/SPSSStatistics.app/Contents/bin/spssprod.inf
chown root:admin /Applications/IBM/SPSS/Statistics/25/SPSSStatistics.app/Contents/bin/spssprod.inf
chmod 775 /Applications/IBM/SPSS/Statistics/25/SPSSStatistics.app/Contents/bin/spssprod.inf

/bin/rm -R /private/tmp/SPSS_Statistics_Installer.bin
/bin/rm -R /private/tmp/installer25ConCurrentL2CLS.properties

exit 0

ryan_ball
Valued Contributor

@rwp16 If you are confident that it works and you just don't want to see the error you can change the install line to this:

/private/tmp/SPSS_Statistics_Installer.bin -f /private/tmp/installer25ConCurrentL2CLS.properties 2> /dev/null

That will ignore the error.

But obviously if the error is avoidable, trying to eliminate the error is best if possible ala @mm2270.

leslie
Contributor II

@seann is correct, the error from the called script still causes the policy to show failed. If I redirect the output to a file though things look to work. Agree with @mm2270 in that it'd be nice to just resolve the install error. However, if you're interested this worked for me.

#!/bin/bash
install_result=$(/path/to/SPSS_installer_script;echo $? &> /tmp/error)

error_code=$(cat /tmp/error)
echo "error code: $error_code"

case $error_code in
    0|127|208)
        echo "successfully installed."
        exit 0
        ;;
    *)
        echo "failed to install.  result: $error_code"
        exit "$error_code"
        ;;
esac

I added 127 as an acceptable error code as that's what my test script generated. You'll notice in the policy log it captured the 127 error but shows a successful install (line 6).
986c925b0f9841cd9efaecda1bce3165

rwp16
New Contributor

Hi All. I would love to correct the error. I even contacted IBM. They told me that they were unfamiliar with the error. Currently I am just going into the log section of the policy and flush all the failures. The machines are then excluded from it because I am scoped to a Smart Group that determines if SPSS is installed or not. The install completes successfully and the program works for users as expected.

@ryan.ball Hi Ryan. Thanks for your response. I tried adding the 2> /dev/null to the install line but it still reports back failed.

@leslie Hi Leslie. Thanks for your response. I'm fairly new to Jamf (about 2 months). Are you suggesting that I added the content above to the beginning of my current script.

Thanks All,
Rusty

leslie
Contributor II

@rwp16 I'd add the above script to your Jamf server (Settings -> Computer Management -> Scripts), after correcting the path for the SPSS installer script. Then change whatever policy you had to kick off the SPSS installer script to kick off the above script instead. Which then launches the SPSS installer script.

Shamagi
New Contributor II

Hi

Set script to give better error messaging

set -eux

The -e means that Bash must exit immediately when a command fails. So the script ends and never executes the "exit 0" line.

Regards

tlarkin
Honored Contributor

What does this mean? Looks like this is your error message as far as I can tell:

Unable to find authenticator properties

Do you need to license this app or authenticate against a service for it?

rwp16
New Contributor

Thanks everyone for the input. The app does get license but it uses a network concurrent license. I tried many methods that were suggested and couldn't get anything to work. Keep in mind that the installation would complete and the app was fully functional and licensed. It just wouldn't report back to Jamf as successfull. What I did as a work around to get a "Completed" status in the Jamf policy was add a " || true " to the end of the install line so that the script wouldn't error out.

/private/tmp/SPSS_Statistics_Installer.bin -f /private/tmp/installer25ConCurrentL2CLS.properties || true