在groovy脚本中从ant - sshexec获得良好的输出

jub*_*ubi 3 ant ssh groovy

我的问题是,ant任务alwas的输出在开头有一些[ssh-exec]信息文本.我能抑制/禁用吗?

我的代码到目前为止:

def ant = new AntBuilder()

// .... variable definition ...

ant.sshexec(host: host,
            port: port,
            trust: true,
            username: username,
            password: password,
            command: 'ls')

>>> output:

  [sshexec] Connecting to foomachine.local:22
  [sshexec] cmd : ls
  [sshexec] oldarchive.gz
  [sshexec] newarchive.gz
  [sshexec] empty-db.sh
  [sshexec] testfile.py
Run Code Online (Sandbox Code Playgroud)

我只想要cmd的原始输出执行...

一些想法?!

Chr*_*orf 10

您可以将原始输出保存在Ant属性中:

def ant = new AntBuilder()
ant.sshexec(host: host,
            port: port,
            trust: true,
            username: username,
            password: password,
            command: 'ls',
            outputproperty: 'result')

def result = ant.project.properties.'result'
Run Code Online (Sandbox Code Playgroud)

  • 如果它正是你想要的,我建议你接受答案!:) (2认同)