Skip to main content
Question

Policy script works when manually triggered but fails on ongoing event...

  • November 15, 2013
  • 3 replies
  • 38 views

Forum|alt.badge.img+2

I have created a very simple script that tells an application to generate a text log. A policy is in place to run this script as a part of the ongoing checkin.

#!/bin/sh
sudo promiseutil -C phydrv > /PegasusLog/log.txt

If I run sudo jamf policy in terminal it will successfully create the log.txt file with the appropriate output. Once the computer checks back in to the JSS though and tries to execute the script it will exit with exit code 5. It also overwrites the log.txt file with a blank log.txt file. What am I missing here?

3 replies

Forum|alt.badge.img+16
  • Honored Contributor
  • November 18, 2013

First, you don't need to write a "sudo" in a bash script because all scripts are run as root. Add a second ">" for your output to get the log added to a text file. AND, just to create a clean script, add an exit code to your script.
Your command should look like these:

#!/bin/sh
promiseutil -C phydrv >> /PegasusLog/log.txt
exit 0


Forum|alt.badge.img+2
  • Author
  • New Contributor
  • November 18, 2013

Thanks for the input. It is still creating a blank text file when the computer checks into the JSS. If I do a jamf policy command though it will create the file correctly. Additionally, I didn't use >> because I don't want it to be a running log. Just a status. Any other ideas as to what could going on? I appreciate the help, I'm a python person so bash makes me unhappy.


Forum|alt.badge.img+16
  • Honored Contributor
  • November 19, 2013

Still a few things to test :)
Please try the following:

Change the path to promiseutil to the full path. Perhaps the output of the promiseutil is on the error channel, so redirect all outputs:
/path/to/promiseutil -C phydrv 2>&1 > /PegasusLog/log.txt