Show, via script, which trigger launched the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-18-2016 07:11 AM
Is there a variable or something that can be used in a script to show which trigger launched the script?
- Labels:
-
Scripts

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-18-2016 07:19 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-18-2016 07:54 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-18-2016 08:02 AM
You could parse the end of the jamf.log maybe, but that is not something the script is aware of normally.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-18-2016 08:03 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-18-2016 08:17 AM
Thanks for the help guys. If something comes to mind, let me know. Until then, I'll put in a feature request.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-18-2016 08:20 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 07-18-2016 02:31 PM
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.
