Display User UID

maiksanftenberg
Contributor II

Hi.

I tried to fetch the current users UID for a script

echo "checking Users UID"
UID=id -u $loggedInUser
echo "$UID"

The output is: Desktop/user_info.sh: line 44: UID: readonly variable
Further there was the idea to check if this is a UID between 501 and 1000 to display if it's a local or AD/OD account.

It would be nice if anybody has an idea how I could approach that?!

Thanks,
Maik

1 ACCEPTED SOLUTION

karthikeyan_mac
Valued Contributor

Hi Maik,

UID is a system reserved variable with information about the user id, Please use some other variable

echo "checking Users UID"
UID1=id -u $loggedInUser
echo "$UID1"

Also quote id -u $loggedInUser to store the output of the command to variable

Thanks & Regards,
Karthikeyan

View solution in original post

3 REPLIES 3

karthikeyan_mac
Valued Contributor

Hi Maik,

UID is a system reserved variable with information about the user id, Please use some other variable

echo "checking Users UID"
UID1=id -u $loggedInUser
echo "$UID1"

Also quote id -u $loggedInUser to store the output of the command to variable

Thanks & Regards,
Karthikeyan

karthikeyan_mac
Valued Contributor

` quote in jamfnation considers as script so i missed it. Thanks

maiksanftenberg
Contributor II

Lesson learned.
Thanks for that.