在Linux下使用ProcessBuilder调用Graphviz

时间:2018-07-31 16:11:07

标签: java linux bash processbuilder

我想使用ProcessBuilder运行Graphviz的dot命令,该命令随后将读取一些输入文件并生成图像。我有以下在Windows下工作的代码:

ProcessBuilder pb = new ProcessBuilder("cmd","/c","start","/wait","dot","-Tpng","graph.dot","-o","graph.png");
try{
Process p = pb.start();
p.waitFor();
}catch(IOException | InterruptedException e) {
        e.printStackTrace();
    }

我现在正在尝试在linux中运行程序,但是我似乎无法执行命令。我尝试运行

pb = new ProcessBuilder("/bin/bash","-c","-wait","dot","-Tpng","graph2.dot","-o","graph.png");
pb = new ProcessBuilder("/bin/bash","-c","-wait","./dot","-Tpng","graph2.dot","-o","graph.png");
pb = new ProcessBuilder("/bin/bash","-c","-wait","./dot","-Tpng","./graph2.dot","-o","./graph.png");
pb = new ProcessBuilder("/bin/bash","-c","dot","-Tpng","graph2.dot","-o","graph.png");
pb = new ProcessBuilder("/bin/bash","-c","./dot","-Tpng","graph2.dot","-o","graph.png");
pb = new ProcessBuilder("/bin/bash","-c","./dot","-Tpng","./graph2.dot","-o","./graph.png");

所有这些都不起作用。

我的工作Windows命令的linux等效命令是什么?

0 个答案:

没有答案