【发布时间】:2019-04-12 15:41:16
【问题描述】:
我无法通过在 Groovy 中执行 shell 脚本获得返回码(不是输出或错误)。
对于我尝试的所有方法,它要么要求我转义,要么只打印 $?而不是给我 1 或 0。
groovy: 75: 美元符号后面的非法字符串主体字符; 解决方案:要么转义文字美元符号“\$5”,要么将值表达式“${5}”括起来@第 75 行,第 24 列。
以下是我尝试过的解决方案,都不起作用。
println "../src/check_job_log.s ${it}.log".execute().text
println "Check log ${it}.log completed"
//assert ("echo \$?".execute().text == "1")
//output = """echo $?""".execute().text
println(['echo', '$?'].execute().text)
// below is code for @that other guy
//def process = "echo hello world".execute()
def process = "../src/check_job_log.s ${it}.log".execute()
print "Output: " + process.text
print "Exit code: " + process.exitValue()
Output: Exit code: 01
【问题讨论】:
标签: shell groovy return-value