Most of my scripting experience is in Powershell and not shell scripting. I'm trying to create an extension attribute in JAMF Pro that checks if the Jamf Connect user is logged into a device. I can get the script to work in Terminal and spit out the information I want. However, after waiting a day, it's still not populating the results in Jamf Pro under the computer record. I'm sure I'm missing some command that sends the data to Jamf, but not sure what that would be.
jamfConnectStateLocation=/Users/$currentUser/Library/Preferences/com.jamf.connect.state.plist
CurrentPassword=$(defaults read com.jamf.connect.state PasswordCurrent)
if [[ $CurrentPassword == 1 ]]; then
echo “User is logged in”
elif li $CurrentPassword == 0 ]]; then
echo “User is not logged in”
fi
The above is the script that works in terminal. I've tried adding echo "<result>$CurrentPassword</result>" on the end, but that spits back an error that result is not a recognized command.
I've also tried changing the script to be the following
jamfConnectStateLocation=/Users/$currentUser/Library/Preferences/com.jamf.connect.state.plist
CurrentPassword=$(defaults read com.jamf.connect.state PasswordCurrent)
if r $CurrentPassword == 1 ]]; then
RESULT=“User is logged in”
elif
RESULT=“User is not logged in”
fi
Echo "<result>${RESULT}</result>"
But this just spits out an error message and doesn't return anything. Any help would be greatly appreciated!