Run Program on Mac for unix "which" commandI'm trying to use the Run Program() command to execute the unix command "/usr/bin/which -a Python3". I'm still learning so sorry if the answer seems obvious. For the record, I'm running JMP Pro 17.2 on MacOS Sonoma 14.7.1. The Mac thing is important to note, as there seem to be some subtle syntax differences from PCs.
Attempt 1 (just confirming Run Program works):
RP = Run Program(
Executable("/usr/bin/which"),
Options({"Python3"}), //No "-a" modifier
readFunction("text")
);
This doesn't give any error, but only returns one instance of Python3 ("/usr/bin/Python3"), and I'm looking for all instances of Python3 on the user's computer. But it at least demonstrates to me that I can get the Run Program function to work.
Attempt 2 (adding the "-a" modifier):
RP = Run Program(
Executable("/usr/bin/which"),
Options({"-a Python3"}),
readFunction("text")
);
This fails, and returns:
"/usr/bin/which: illegal option --
usage: which [-as] program ...
"
Attempt 3 (using slightly different syntax):
RP = Run Program(
Executable("/usr/bin/which"),
Options({"-a", "Python3"}), //"-a" is now a separate list item
readFunction("text")
);
This does not fail, but returns the same thing as in my first attempt (as if there were no "-a" modifier):
Attempt 4 (creating a bash script and executing the 'which' command from that instead):
I created the simple text file and saved to my Desktop
#!/bin/bash
/usr/bin/which -a python3
Then I ran this in JMP:
</CODE><CODE class=" language-jsl">RP = Run Program(
Executable("/bin/sh"),
Options({"/Users/stefannikles/Desktop/usrbinwhich.txt"}),
readFunction("text")
);
This did not return an error, but only "".
I've tried several other things, but none seem to work. Any advice anyone can provide will be appreciated. Thanks.
Automation and ScriptingmacOSRe: Help on using "Run Program"#3 is a correct way on Mac. On Win, #2 would also work. What version of JMP? I'll guess the more recent versions of JMP may do something to make the internal version of Python happy and you might be seeing a side effect. @Paul_Nelson
#4 maybe bin/sh is not a shell that supports the -a parameter?
Re: Help on using "Run Program"Thanks Craig. #3 does not work for me. Just curious, were you able to confirm #3 works on your Mac? I tried on a user's computer with 4 instances of Python, but only one Python path is returned. Same result on mine. I'm running JMP Pro 17.2 on MacOS Sonoma 14.7.1. I'm told JMP 18 has python built-in, but our org still uses 17.2.
Re: Help on using "Run Program"No mac here, sorry. I did run the -a on Linux to see the output. On mac, it is necessary to split up the parameters like you did in 3. On win, they get re-parsed from a constructed command line, but not on mac.
Re: Help on using "Run Program"/usr/bin/python3 is one shipped with macOS for use by macOS, it is not a current Python, but the only on returned by the program which. All Python.org installs go to /Library/Frameworks/Python.framework
On my macOS Sonoma 14.7.5 I have Python 3.10, 3.11, 3.12, 3.13 ( and /usr/bin/python3 is 3.9.6 )
-rwxr-xr-x 77 root wheel 119008 Mar 19 15:20 /usr/bin/python3*
me@my_machine ~ % file /usr/bin/pyth
/usr/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python3 (for architecture arm64e): Mach-O 64-bit executable arm64e
me@my_machine ~ % /usr/bin/python3
Python 3.9.6 (default, Oct 4 2024, 08:01:31)
[Clang 16.0.0 (clang-1600.0.26.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
me@my_machine ~ % ls -l /Library/Frameworks/Python.framework/Versions
total 0
drwxrwxr-x 12 root admin 384 Apr 17 10:29 3.10/
drwxr-xr-x 10 me staff 320 Apr 10 15:35 3.11/
drwxrwxr-x 11 root admin 352 Apr 17 10:31 3.12/
drwxrwxr-x@ 12 root admin 384 Apr 8 16:26 3.13/
lrwxr-xr-x 1 root wheel 4 Apr 17 10:31 Current@ -> 3.12
The last Python installed is the one pointed to by Current, I installed the latest binary update for Python 3.12.
JMP 18 ships with an embedded Python 3.11.x. The JMP 18.2.1 release has been updated with Python 3.11.12 security update. JMP 19 EA's are installed with the most current Python 3.13.x
Note on suitable Python versions: JMP does not support connection to Anaconda Python, only Python.org Python is supported. With JMP 18 and JMP 19, only the Python supplied by JMP works with JMP. But that Python works right out of the box the moment you launch JMP. JMP 18 and forward give you a Python script editor as well as the JSL script editor, and the Python code has access to data tables and ability to call JSL from Python, just as you can now call Python from JSL. JMP 17 on the Mac should just find the current Python in /Library/Frameworks/Python.framework with the Python Init()