Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Setting environment path for system.callSystem()?

Enthusiast ,
Mar 12, 2017 Mar 12, 2017

I'm running macOS Sierra.

In my ExtendScript code I have:

system.callSystem("echo $PATH");

This results in the following output in the ESTK's Javascript Console:

/usr/bin:/bin:/usr/sbin:/sbin

However, if I enter the same command directly in a terminal window, like so:

echo $PATH

The following is output:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

So it seems that ExtendScript operates in a different environment than the one my user has?  I'm not understanding why the $PATH variable is showing differently in the two different contexts.  The documentation for system.callSystem state:

Executes a system command, as if you had typed it on the operating system’s command line. Returns whatever the system outputs in response to the command, if anything.

Is there anything I can do ensure that the system.callSystem method makes use of my current environment path?

Thanks!

TOPICS
Scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Mar 12, 2017 Mar 12, 2017

Alright, I found an answer that seems to work even after rebooting the system—so it's a permament fix.  I found the answer a bit of the way down on this thread at AskDifferent:

Start a terminal session and enter the following.

sudo launchctl config user path /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Of course, instead of the specific path above, insert the environment path you want AE to have on macOS, then reboot the machine.

Any .bash_profile or .profile files in your Home directory will be hon

...
Translate
Enthusiast ,
Mar 12, 2017 Mar 12, 2017

Alright, so I pin pointed the issue, and have learned a new detail about the system.callSystem method.  On macOS, callSystem seems like it sources the .bash_profile found in the user's home folder.  Since upgrading to macOS, I added a .profile file that handled setting up paths, etc.  So, I essentially had to create a .bash_profile file and setup the environment path in there.  After doing that, AE loads with the same environment path.

So, that doesn't seem to be it after all.  The issue is returning after a restart of AE and ESTK.  Anybody have any ideas why this is the case on macOS Sierra?  I don't have any older OSX installations so I cannot recall if the behavior is different for different versions of OSX.

On Windows, the user path is recognized when doing system.callSystem("echo %PATH%") — but when doing so, AE magically prepends the "Support Files" directory found within AE's application directory.

Thanks,
Arie

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 12, 2017 Mar 12, 2017
LATEST

Alright, I found an answer that seems to work even after rebooting the system—so it's a permament fix.  I found the answer a bit of the way down on this thread at AskDifferent:

Start a terminal session and enter the following.

sudo launchctl config user path /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Of course, instead of the specific path above, insert the environment path you want AE to have on macOS, then reboot the machine.

Any .bash_profile or .profile files in your Home directory will be honored when you start a Terminal session.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines