使用 Groovy 调用 cmd 并且 SoapUI 不工作

Invoking cmd with Groovy and SoapUI not working

我正在使用 SoapUI 测试网络服务。我的客户端 运行s Windows 7 和服务器 运行s Linux。对于某些测试用例,我需要更改远程服务器上的配置文件。我想用 groovy 脚本来实现这一点。第一步是使用 scp (kscp) 推送文件,第二步是通过 ssh (kitty) 重新启动应用程序。

第一个命令不起作用。第二个就好了。我做错了什么?

def scp = Runtime.getRuntime().exec("C:/pathTo/kscp.exe -pw password fileToUpload.txt user@host:/pathTo/remoteLocation/")
scp.waitFor()
def ssh = Runtime.getRuntime().exec("C:/pathTo/kitty.exe -load profile -m C:/pathTo/scriptToBeRunOnRemote")
ssh.waitFor()

如果我在普通 cmd 中执行第一个命令,它就可以正常工作。我还尝试 运行 来自 .bat 文件的相同命令但没有成功。

提前感谢您的帮助和提示!

编辑(已找到解决方案)

我刚刚找到了解决方案。

def scp = Runtime.getRuntime().exec("cmd /c cd C:/pathTo/ & kscp.exe -pw password fileToUpload.txt user@host:/pathTo/remoteLocation/")

找到解决方案

def scp = Runtime.getRuntime().exec("cmd /c cd C:/pathTo/ & kscp.exe -pw password fileToUpload.txt user@host:/pathTo/remoteLocation/")