zeroturnaround / zt-exec

ZeroTurnaround Process Executor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No such file or directory

ardenliu opened this issue · comments

String output = new ProcessExecutor().command(commandToLoadXml).readOutput(true).execute().outputUTF8();

The value of commandToLoadXml is :

/usr/bin/python3 /home/arden/dev/git/Arelle/arelleCmdLine.py -f "/home/arden/dev/xbrl/fb-20180930.xml" -v --plugins xbrlDB --store-to-XBRL-DB localhost,5432,postgres,postgres6161,xbrlam,90,pgSemantic

I can run that command from command line window, but I go the following exception:

Caused by: java.io.IOException: Cannot run program "/usr/bin/python3 /home/arden/dev/git/Arelle/arelleCmdLine.py -f "/home/arden/dev/xbrl/fb-20180930.xml" -v --plugins xbrlDB --store-to-XBRL-DB localhost,5432,postgres,postgres6161,xbrlam,90,pgSemantic": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at org.zeroturnaround.exec.ProcessExecutor.invokeStart(ProcessExecutor.java:997)

I think you need to split the arguments into separate arguments of the command method call. For example

String output = new ProcessExecutor().command("java", "-version")
                  .readOutput(true).execute()
                  .outputUTF8();    

As @toomasr said, if /usr/bin/python3 exists, it seems that you're running the whole command including arguments. It would work in terminal, but generally won't from code, as something that looks like a single string in terminal is not treated as a single string when you call a command from code. When you're calling a command from code, you must separate the binary from the arguments.