【发布时间】:2012-09-12 20:04:55
【问题描述】:
我想从我的 groovy 脚本中执行 shell 命令。 我测试了以下内容:
"mkdir testdir".execute()
这很好用。 现在我想创建一个文件,向文件中写入一些内容,然后打开文本编辑器来查看文件。
def execute(cmd) {
def proc = cmd.execute()
proc.waitFor()
}
execute("touch file")
execute("echo hello > file")
execute("gedit file")
现在 gedit 可以正确打开,但文件中没有“hello”字符串。 这是怎么回事?!?
【问题讨论】: