[Q] Using $.getenv
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);
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 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
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.