Skip to main content

where can we find the variable of jamf built in for example $3(currentuser) $4(xxxx) or learn OS script.



i can write bash a little. but not Apple script for example



sudo installer -pkg ......


i want learn to write some script for apple script.

What is it you are trying to achieve?



To get a username as an example the recommended code, which allows for fast user switching is:



#!/bin/sh
# Get the username
User_Name=`/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`


To install a package it would be something like:



#!/bin/sh
installer -pkg "mygreatpkg.pkg" -target "/" -dumplog


To use applescript inside a shell, then osascript is what your looking for:



#!/bin/sh
# Make a login item.
/usr/bin/osascript <<EOF
tell application "System Events" to make login item at end with properties {Path:"$App_Path", name:"$Item", hidden:$Hidden}
EOF


There are plenty of script resources on JamfNation - https://www.jamf.com/jamf-nation/third-party-products/files/scripts Or check out github. It really does depend on what you are trying to achieve.


Hi, I think https://www.jamf.com/jamf-nation/articles/146/script-parameters explains nicely what the parameters are and how they can be set.