在Groovy里可以很方便的得到命令行的返回值(exitValue函数):

 

def cmd ="ls -lrt " 
def proc =cmd.execute() 
proc.waitFor()  // 用以等待外部进程调用结束 
println proc.exitValue()

 

如果需要在特定的folder运行可以用下面的代码

path -- 相当于运行目录

cmd.execute(null, new File(path))

 

相关文章:

  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-21
  • 2022-12-23
  • 2021-05-18
  • 2022-03-04
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案