更新时间:2022-11-30 15:56:07
你由于它由shell处理,因此在此处不能使用 |
。或者使用 sh -c
来执行或管理自己。请参阅 http://groovy.codehaus.org/Process+Management
you can not use |
here as it is handled by the shell. either use sh -c
to execute or pipe yourself. See http://groovy.codehaus.org/Process+Management
def p = ['sh', '-c', 'ls /tmp | grep groovy'].execute()
p.waitFor()
println p.text
或
def p1 = 'ls /tmp'.execute()
def p2 = 'grep groovy'.execute()
p1 | p2
p2.waitFor()
println p2.text