Posted on 11-06-2018 01:47 AM
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.
Solved! Go to Solution.
Posted on 11-06-2018 02:27 AM
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.
Posted on 11-06-2018 02:27 AM
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.
Posted on 11-06-2018 07:19 AM
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.