0

I have many layers of problems that I'm trying to work through, and I've found one potential way around the main problem, but I've run into another in the process.

Within a Scriptrunner Groovy script, I am trying run a separate (python) script using .execute() on a string that contains the full path. Unfortunately the path contains a space and no matter how I try to escape the space, it truncates the command at the space.

i.e.

def cmd = "D:/Path/To The File/python_executable"
def proc = cmd.execute()

And the error is

java.io.IOException: Cannot run program "D:/Path/To": CreateProcess error=193, %1 is not a valid Win32 application

This question has a similar problem, but it's running java on the command line, which which I don't have access to (as far as I know). Also the top answer suggests command line actions that again I can't do in this setting.

Unfortunately I'm stuck with the directory names because of Scriptrunner/JSD. Is there any way I can make this work?

Vy Do
  • 46,709
  • 59
  • 215
  • 313
Bamboo
  • 973
  • 7
  • 17
  • Well, I guess this is a Windows machine. Why don't you try to quote the path? I mean, can you try something like `"\"D:/Path/To The File/python_executable\""` ? – stuck Jan 13 '22 at 04:05
  • @stuck unfortunately it seems that doesn't work either, it still truncates – Bamboo Jan 13 '22 at 05:26
  • Ok, what if we change the working dir? Can you try something like that: `File workingDirectory = file(“D:/Path/To The File”) “python_executable”.execute([], workingDirectory.absolutePath); ` – stuck Jan 13 '22 at 15:40
  • @stuck Thanks for that, I managed to get past the truncation by using a variation of this: `def wd = new File("D:/Path/To The File/"); def result = "python_executable".execute([], wd)`. Now, for some reason it can't find the file even though its the correct path, but that's another problem... – Bamboo Jan 14 '22 at 02:42

0 Answers0