Extension Attribute

JMontey1
New Contributor III

I am trying to get this script to work for this extension attribute. It's just not pulling anything in Jamf Pro. But when I run the same commands in terminal on the local machine, as root, it works. Any suggestions?

Screenshot 2024-03-21 at 7.44.25 PM.png

 

Screenshot 2024-03-21 at 7.50.25 PM.png

 

Screenshot 2024-03-21 at 7.22.31 PM.png

 

Screenshot 2024-03-21 at 7.42.17 PM.png

1 ACCEPTED SOLUTION

sdagley
Esteemed Contributor II

@JMontey1 In the EA listing you show you're missing a / at the beginning of the path to version.txt file.

You might also want to re-think your check for the current user. Here's a pretty definitive writeup on the best way to do that: https://scriptingosx.com/2020/02/getting-the-current-user-in-macos-update/

View solution in original post

4 REPLIES 4

sdagley
Esteemed Contributor II

@JMontey1 In the EA listing you show you're missing a / at the beginning of the path to version.txt file.

You might also want to re-think your check for the current user. Here's a pretty definitive writeup on the best way to do that: https://scriptingosx.com/2020/02/getting-the-current-user-in-macos-update/

howie_isaacks
Valued Contributor II

This command has always worked for me.

currentUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`

I have this in a text document along with a bunch of other commonly used commands and functions that I copy and paste into my scripts. I have always wondered if the other commands worked better in certain use cases or when used with a different interpreter.

JMontey1
New Contributor III

The currentUser part works fine. I know there's other options. 

The / was missing before "Users" in the file path, that was ultimately what fixed the script. 

 

Thank you all for your help and suggestions. I am slowly throwing myself in the scripting fire so this is all new and exciting. 

howie_isaacks
Valued Contributor II

You picked the best place to get help. Many Jamf Nation members have helped me learn to script better. @sdagley is one of them. Mac Admins Slack is another great place to get help.