Skip to main content
Question

logon logoff script

  • January 31, 2023
  • 1 reply
  • 0 views

brizkallah
Forum|alt.badge.img+3

hellow community, i need your help today with a DEALY issue after applying the following script in Jamf Pro. 

after adding the script into Jamf there is a delay with the logon for the end user.

username="$3"
serialnumber="$(ioreg -c IOPlatformExpertDevice -d 2 | awk -F\\" '/IOPlatformSerialNumber/{print $(NF-1)}')"
ip="$(ifconfig | grep 'inet 10' | grep -m1 -o '\\d\\{1,3\\}\\.\\d\\{1,3\\}\\.\\d\\{1,3\\}\\.\\d\\{1,3\\}' | grep -m1 '10')"

#echo ${username} >> /usr/local/bin/Logs/logs.txt
#echo ${serialnumber} >> /usr/local/bin/Logs/logs.txt
#echo ${ip} >> /usr/local/bin/Logs/logs.txt

1 reply

AJPinto
Forum|alt.badge.img+26
  • Legendary Contributor
  • 2716 replies
  • January 31, 2023

Why are you trying to capture the SN, JAMF Assigned user name, IP, and user name at each log in? JAMF Already captures all this information from macOS's logs.

 

If you must do this, I would recommend making it a launchdaemon and cut JAMF out of it. Also >> will not create a directory, so if /usr/local/bin/logs does not exist it will error out. I would also replace $3 with a function to grab the logged in user from the Mac rather than JAMF.

 

Something like this may work better. Also do not use 777 as that is world writable, this is just for a simple example.

#!/bin/bash username=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }' | tr "[a-z]" "[A-Z]"` serialnumber="$(ioreg -c IOPlatformExpertDevice -d 2 | awk -F\\" '/IOPlatformSerialNumber/{print $(NF-1)}')" ip="$(ifconfig | grep 'inet 10' | grep -m1 -o '\\d\\{1,3\\}\\.\\d\\{1,3\\}\\.\\d\\{1,3\\}\\.\\d\\{1,3\\}' | grep -m1 '10')" if [ -d "/usr/local/bin/Logs" ] then echo '/usr/local/bin/Logs/ Exists, writing log' sudo echo ${username} >> /usr/local/bin/Logs/logs.txt sudo echo ${serialnumber} >> /usr/local/bin/Logs/logs.txt sudo echo ${ip} >> /usr/local/bin/Logs/logs.txt else echo '/usr/local/bin/Logs/ does not exist, creating directory' sudo mkdir "/usr/local/bin/Logs/" sudo chmod 777 "/usr/local/bin/Logs/" sudo echo ${username} >> /usr/local/bin/Logs/logs.txt sudo echo ${serialnumber} >> /usr/local/bin/Logs/logs.txt sudo echo ${ip} >> /usr/local/bin/Logs/logs.txt fi

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings