Log to "Result of Command" portion of log from a Policy > Advanced > Run Command action

beneb
New Contributor III

Hi:

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:

Thanks all

3 REPLIES 3

mm2270
Legendary Contributor II

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

beneb
New Contributor III

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.

mm2270
Legendary Contributor II

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.