Skip to main content
Solved

Display User UID

  • March 13, 2015
  • 3 replies
  • 8 views

Forum|alt.badge.img+9

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

Best answer by karthikeyan_mac

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

3 replies

karthikeyan_mac
Forum|alt.badge.img+18
  • Honored Contributor
  • Answer
  • March 13, 2015

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
Forum|alt.badge.img+18

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


Forum|alt.badge.img+9
  • Author
  • Valued Contributor
  • March 16, 2015

Lesson learned.
Thanks for that.