我有以下 Groovy 脚本:
#!/opt/groovy-1.8.6/bin/groovy
final env = null // []
final command = ["./setter-for-catan.scala"]
final process = command.execute(env, null)
println (['echo', '********************** 0'].execute(env, null).text)
final stdout = process.inputStream
BufferedReader reader = new BufferedReader(new InputStreamReader(stdout))
while ((line = reader.readLine()) != null) {
System.out.println ("Stdout: " + line);
}
和以下 Scala 脚本:
#!/bin/bash
export SCALA_HOME=/opt/scala-2.10.1
echo '********************* 1' "$0" "$@"
${SCALA_HOME}/bin/scala -version 2>&1
exec ${SCALA_HOME}/bin/scala "$0" "$@" 2>&1
!#
println("******************* 2")
调用 Groovy 脚本输出:
********************** 0
Stdout: ********************* 1 ./setter-for-catan.scala
Stdout: Scala code runner version 2.10.1 -- Copyright 2002-2013, LAMP/EPFL
Stdout: ******************* 2
如果env
定义为[]
,则 Groovy 脚本会挂起并显示以下输出:
********************** 0
Stdout: ********************* 1 ./setter-for-catan.scala
Stdout: Scala code runner version 2.10.1 -- Copyright 2002-2013, LAMP/EPFL
发生了什么事,需要做什么才能execute()
不挂起?env
Array