Copy link to clipboard
Copied
I was trying to use $.getenv on MacOS but it returns 'undefined'. Am I misunderstanding how to use it?
var envname;
$.getenv(envname);
$.writeln(envname);
Hi @tomd75724979, I've never actually used it, but I had a quick look and here's what I noticed:
First, see this note in the docs specifically for MacOS:
So it claims to use launchctl setenv. So you can do this:
1. In a terminal session, type this:
launchctl setenv "foo" "bar"
2. launch Illustrator (the var won't be available to Illustrator unless it launches after step 1).
3. run this ExtendScript
// read "foo" key, alerts "bar"
alert($.getenv('foo');
Note: these vars are not persi
...Copy link to clipboard
Copied
Hi @tomd75724979, I've never actually used it, but I had a quick look and here's what I noticed:
First, see this note in the docs specifically for MacOS:
So it claims to use launchctl setenv. So you can do this:
1. In a terminal session, type this:
launchctl setenv "foo" "bar"
2. launch Illustrator (the var won't be available to Illustrator unless it launches after step 1).
3. run this ExtendScript
// read "foo" key, alerts "bar"
alert($.getenv('foo');
Note: these vars are not persisent across system restarts.
Also note that you can do it all from in ExtendScript itself:
// write
$.setenv('foo','baz');
// read
$.writeln($.getenv('foo'));
and this var will persist as long as Illustrator is open. However, I don't think you will be able to read a var set in ExtendScript from outside, eg. by launchctl getenv "foo" because environment vars set this way seem to be passed from parent process to child, so don't go back up and to another process, eg. a terminal.
That's all I could tell at a quick look. Hopefully there are some experts on here that may shed more light.
- Mark
Copy link to clipboard
Copied
Hi Mark,
Many thanks for your response. I now realise I completely misunderstood this. I thought this would return the machine environment, something like {Apple Macintosh, 14.0} or {Microsoft Windows, 10.x}. But I now understand that it is some overarching variable that can be accessed from multiple scripts.
Copy link to clipboard
Copied
for the os you can use the following. But I'm on Windows 11, so I'm not sure what the 10.0 is
$.os
// Result: Windows/64 10.0
Copy link to clipboard
Copied
Many thanks, Carlos!
For me it returns:
Macintosh OS 14.0.0/64
Which sounds spot on.