Posted on 04-04-2014 08:18 AM
Probably simple and covered before, but not finding the answer. How can we send log output to the "Result of Command" part of the policy log or anywhere in the policy log, when running a command from the run command field? We'll get blank output instead, see below. (Just an example of what we're seeing not an actual command we're running).
Running command if [ -e /Users/user/ ]; echo "User exists"; else echo "User does not exist"; fi; exit 0
Result of command:
Posted on 04-04-2014 09:01 AM
I've noticed that too. I don't particularly love using the Run Command field if I'm expecting output I can use later, since it isn't the best at that.
But you can try doing something like this. While it doesn't actually show you the "Result of command" output, it can at least echo out the result from the script.
if [ -e /Users/user/ ]; then x="User exists"; else x="User does not exist"; fi; echo "$x"; exit 0
Running command if [ -e /Users/user/ ]; then x="User exists"; else x="User does not exist"; fi; echo "$x"; echo $?; exit 0.... User exists
Posted on 04-04-2014 09:30 AM
Thanks for responding. I really like using the field because it doesn't mount a distribution point and I don't have to create another .sh file, etc., but if I can't get any results maybe its not worth it. The weird thing is, even with your script, I still don't get any output. Here's what I get
Running command if [ -e /Users/user/ ]; then x="User exists"; else x="User does not exist"; fi; echo "$x"; exit 0...
Result of command:
In terminal (i'm kicking the test off using "sudo jamf policy -trigger test", though I don't think thats the issue), I get the "User exists" output but not in the policy log.
Thanks again, hopefully there is a way to do this.
Posted on 04-04-2014 10:24 AM
I ran my command above from Casper Remote, and I got the echo result in the Log. Was your test run from a regular policy? I haven't tested that.