Posted on 07-18-2017 11:07 AM
Hi
I'm busy creating extension attribute scripts, and would like to be able to use the same scripts whether I'm running them in JAMF or independently on our Macs.
When I'm creating a JAMF extension attribute, I obviously need to add the <result></result> tags at the end, whereas if running the same script directly on a mac, I don't need these tags.
Is there a way to check the environment that the script is running in so that I can then choose whether to add the tags or not?
Any ideas welcome!
Cheers,
Mags
Solved! Go to Solution.
Posted on 07-18-2017 12:34 PM
This command will give the parent process of a script. When running through the JSS, it returns 'sh'. When running locally it returns 'login' or 'sudo' depending on where you're at. I haven't really used this function so I don't know how it would play out, but you might be worth investigating...
PARENT_COMMAND="$(ps -o comm= $PPID)"
echo $PARENT_COMMAND
Posted on 07-18-2017 12:34 PM
This command will give the parent process of a script. When running through the JSS, it returns 'sh'. When running locally it returns 'login' or 'sudo' depending on where you're at. I haven't really used this function so I don't know how it would play out, but you might be worth investigating...
PARENT_COMMAND="$(ps -o comm= $PPID)"
echo $PARENT_COMMAND
Posted on 07-19-2017 02:51 AM
Thanks that's a great help - I can definitely use the parent process to specify whether the script is running in jamf