I’m trying to run a shell command with arguments (i.e.
cmd = "tool -i -o -e "file.txt") from GHPython in Rhino 6 for Mac to post-process some files!
tool is a third-part command-line tool.
os.system(cmd) which works for rudimentary bash commands, but doesn’t seem to be able to call a third-party command-line tool, like it does on Windows? Since it doesn’t output anything useful (prints
1?), not even an error, it’s hard to debug. On Windows, a command prompt window launches and the command runs! On macOS, nothing happens?
I’ve also tried the
subprocess library without much luck!
Only very few functions are even implemented in the terrible and dated IronPython.
subprocess.call(shlex.split(cmd)) throws a
Win32Exception (and that on macOS, I don’t even dare to ask)? By the way,
shlex.split() well splits my command string into a list of strings for
subprocess.call(), which likes it that way.
Runtime error (Win32Exception): Runtime error (Win32Exception): ApplicationName=‘tool’, CommandLine=’-i -o -e file.txt’, CurrentDirectory=’/Users/*****/Desktop/’, Native error= Cannot find the specified file
I have tested the command in macOS Terminal (unix shell) and it runs fine. The tool is properly installed. The text file sits in the right location and I
os.chdir() to the right path beforehand!
Again, I’m trying to invoke a third-party command-line tool with arguments that then runs inside a shell (not Rhino/Grasshopper) and post-processes a file that get’s output beforehand by Rhino. GHPython just needs to launch the shell and communicate the command string! It would be cool, if a command output could be send back to GHPython for debugging, but I’m already more than happy, if I get the first part running!
Any ideas? Thanks.