问题
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