我想执行这个命令“点-Tpng overview.dot > overview.png ",它用于生成图像。
scala中的代码:
Process(Seq("dot -Tpng overview.dot > overview.png"))它不起作用。我还想在scala中打开这个图像。我在Ubuntu工作。默认情况下,图像查看器将打开图像。但是我在终端上输入了"eog overview.png“,它会报告错误。
** (eog:18371): WARNING **: The connection is closed因此,我不知道如何让scala打开这个图像。
提前谢谢。
发布于 2013-12-06 07:02:48
不能在命令字符串中使用stdout重定向>。您应该使用#>和#|运算符。参见process包文档中的示例。
这会将test写入test.txt
import scala.sys.process._
import java.io.File
// use scala.bat instead of scala on Windows
val cmd = Seq("scala", "-e", """println(\"test\")""") #> new File("test.txt")
cmd.!就你而言:
val cmd = "dot -Tpng overview.dot" #> new File("overview.png")
cmd.!或者仅仅是这样(因为dot接受输出文件名为-ooutfile):
"dot -Tpng overview.dot -ooverview.png".!https://stackoverflow.com/questions/20417780
复制相似问题