clojure.java.sh: No such file or directory

非 Y 不嫁゛ 提交于 2021-02-17 02:14:29

问题


I've written a program to assemble .dot files, and want to use Clojure's sh to give a compile command. Specifically, I use the following function to do it:

(defn compile-graphviz
  "Dumps graphviz-string to a file, then compiles it using dot."
  [graphviz-string]
  (do
    (spit "./tree.dot" graphviz-string)
    (sh "dot -Tpng \"/.tree.dot\" -o\"/.tree.png\"")))

However, when I run this, the second part fails, giving the following error message at the REPL:

IOException error=2, No such file or directory  java.lang.UNIXProcess.forkAndExec (UNIXProcess.java:-2)

I've looked at the documentation for sh and examples, and I can't understand why this wouldn't work. What am I missing?


回答1:


According to the documentation, sh uses execve semantics:

(sh "dot" "-Tpng" "/.tree.dot" "-o" "/.tree.png")


来源:https://stackoverflow.com/questions/23577521/clojure-java-sh-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!