Skip to main content
Question

Show, via script, which trigger launched the script

  • July 18, 2016
  • 7 replies
  • 25 views

Forum|alt.badge.img+9

Is there a variable or something that can be used in a script to show which trigger launched the script?

7 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • July 18, 2016

Hmm? Can you explain what you mean by 'which trigger'? Are you talking about the policy triggers, like Recurring Check-in, Login, Logout, etc? Or do you mean something else?


Forum|alt.badge.img+9
  • Author
  • Contributor
  • 79 replies
  • July 18, 2016

If I have a script that has two triggers, Recurring Check-In and Network State Change, I'd like to see which trigger caused the script to launch. That way I can have the script do different things depending on the trigger without having to have multiple scripts and policies.


Forum|alt.badge.img+17
  • Contributor
  • 881 replies
  • July 18, 2016

You could parse the end of the jamf.log maybe, but that is not something the script is aware of normally.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • July 18, 2016

OK, I thought that's what you meant. So, the script is a payload in a policy that can be called by 2 or more different triggers. What you're asking then is how to make the script know which trigger called the owning policy for the script itself.

Its a good question. I'm not certain there's a built in way. I don't think so. But there may be some way of knowing. I'd have to give that some thought.


Forum|alt.badge.img+9
  • Author
  • Contributor
  • 79 replies
  • July 18, 2016

Thanks for the help guys. If something comes to mind, let me know. Until then, I'll put in a feature request.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • July 18, 2016

I thought of parsing the end of the jamf log myself at first, but I doubt that would be highly accurate. Might get lucky a number of times, but you're bound to run into cases where it won't get you the info you're looking for.


Forum|alt.badge.img+16
  • Valued Contributor
  • 1002 replies
  • July 18, 2016

One thing that MIGHT kind of work... Check the $3 variable for a valid username. It would take some testing to confirm but I think if it's only populated if it was called by login or self service, so if it's not then it was some other type of trigger.