groovyスクリプトからシェルコマンドを実行したい。私は以下をテストしました:
"mkdir testdir".execute()
これは問題なく機能します。ここで、ファイルを作成し、ファイルに何かを書き込んでから、テキストエディターを開いてファイルを表示したいと思いました。
def execute(cmd) {
def proc = cmd.execute()
proc.waitFor()
}
execute("touch file")
execute("echo hello > file")
execute("gedit file")
これでgeditは正しく開きますが、ファイルに「hello」文字列はありません。これはどのように機能していますか?!?