运行 安装在 windows 机器上的 SoapUI 在 unix 系统上的命令

Run the command on unix system by SoapUI installed on windows machine

我需要通过 SoapUI 工具在 unix 系统上执行 unix command/shell 脚本。 SoapUI 安装在 windows 机器上。

  1. 如何通过 SoapUI 与 unix 机器建立 ssh 连接?
  2. 如何运行命令?
  3. 如何捕获此命令的输出?

您可以使用以下代码:

def process = 'ssh user@host myCommand'.execute()
process.waitFor()
println process.in.text
println process.err.text

您可以将其作为 testSuite 或 testCase setUp/tearDown 脚本、脚本测试步骤或任何其他可以执行 groovy 的地方执行。

如果可以的话,我建议配置密钥身份验证,这样在建立连接时就不会要求您输入密码。

您还可以在单​​个连接中执行多个命令:

def process = 'ssh user@host "myCommand1; myCommand2; myCommand3"'.execute()

我更喜欢使用 && 运算符仅在前一个命令成功完成时才执行命令,即:

ssh user@host "myCommand1 && myCommand2 && myCommand3"