Skip to main content
Disposition_Dev
Legend
October 28, 2016
Answered

Determine the user at runtime

  • October 28, 2016
  • 1 reply
  • 530 views

Is there a way to determine the current user at runtime?

I have many people using my scripts daily and I'm working on building a logging and error reporting API so that I can build detailed log files and  accurately identify the source of errors. As part of this, I want to determine which user is currently running the script so i can log that information inside their log entry.

We're all running Macs here, so i need something that works on OSX. Currently I'm just reading the contents of the /Users/ folder (with folder.getFiles()) to find the user's name, but I'm hoping to find something a little more reliable. I can guarantee that each user has a folder in their /Users/ folder with their name on it. However, the /Users/ folder often contains other files and can contain multiple users (for example, i have a 'will.dowling' folder and an 'admin' folder).

I could eventually weed out all of the known undesirable names (.localized, DS Store, etc) but then i still leave myself open to the possibility that someone creates an unexpected file or directory in there.

tldr;

Is there anything in the adobe illustrator API that allows me to accurately read any unique information about the user so I can attach the username to the log file?

Thanks in advance. 😃

This topic has been closed for replies.
Correct answer Silly-V

You can use $.getenv ("USER")  to get the Mac's user names.

1 reply

Silly-V
Silly-VCorrect answer
Legend
October 28, 2016

You can use $.getenv ("USER")  to get the Mac's user names.

Disposition_Dev
Legend
October 28, 2016

Genius, yet again.

Is that documented somewhere? i searched the Scripting Guide and OMV for any mention of the word "user" and came up with nil.

Thanks Vasily.

Silly-V
Legend
October 29, 2016

Hehe, it's actually all over the place here - but generally speaking for things related to non-app-specific commands, you can get a lot of information from the OMV's Javascript Core Objects dictionary help place in the OMV.