groovy"...".execute()在Windows上有效,但在Linux上失败 [英] groovy "...".execute() works on windows but fails on linux
问题描述
此行在我的linux框上的Windows上正常运行时,它返回退出代码1.
while this line works fine on windows on my linux box it returns exit code 1.
"gnuplot -e \"set output '${imageFile.toString()}'; filename='${dataFile.toString()}'; ${args}\" \"${plotFile.toString()}\"".execute()
但是,如果我仅在终端上执行此操作,则一切正常.
But if I execute just this from the terminal everything works.
gnuplot -e "set output '/tmp/hrp-current.jpg'; filename='/tmp/a731265b-3736-4bb9-acf4-b92c1a09b999.csv'; " "/tmp/hrp/build/groovy/../gnuplot/hrp-current.gnuplot"
我在这里想念什么?某种程度上,它与gnuplot写入文件有关,因为在退出代码为1的linux上,"some_command> some.file"也会失败,而在Windows上可以正常工作.
What am I missing here? It somehow has to do with the fact that gnuplot writes to a file because `some_command > some.file" also fails on linux with exit code 1 while it would work fine on windows.
推荐答案
实际上是一些文件写入问题,因此我需要gnuplot将其输出通过管道传输到stdout,然后从groovy脚本中读取它并在其中读取输出流,然后保存到文件中:
Indeed it is some file writing issue so I need gnuplot to pipe its outout to stdout and then consume it from my groovy script where I read the outputstream and then save it to a file:
def out = new ByteArrayOutputStream()
def err = new ByteArrayOutputStream()
process.waitForProcessOutput(out, err)
这篇关于groovy"...".execute()在Windows上有效,但在Linux上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!