Posted on 11-15-2013 02:19 PM
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?
Posted on 11-17-2013 10:24 PM
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
Posted on 11-18-2013 09:07 AM
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.
Posted on 11-19-2013 01:47 AM
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