我有保留在远程服务器(Linux计算机)上的shell脚本,并且试图在Windows的SOAPui的各种测试用例执行之间调用该shell脚本。
所以我准备了一个普通的脚本:

def command="/usr/bin/ssh -p password username@IP_address bash -s < /home/test.sh" 
def proc=command.execute().text 
proc.waitFor() 

但不幸的是,我收到一个错误:

java.io.IOException:无法运行程序“/ usr / bin / ssh”:CreateProcess错误= 2,系统在以下行找不到文件指定的错误:6

我试图对此进行更多搜索,但无法获得解决方案。一些链接是:

How to execute shell script using soapUI

http://groovy-lang.org/groovy-dev-kit.html#process-management

请您参考如下方法:

如果您发表评论,则表示已在Windows上安装了putty.exe,则可以尝试以下操作。

首先,在Windows本地中创建一个带有远程执行命令的文件,例如,我创建以下C:/temp/commandsToRunRemotely.txt,然后在该文件中放入要执行的命令。作为示例,我使用以下命令:

echo "test remote execution" > /tmp/myfile.txt 

然后从SOAPUI中的常规脚本调用 putty.exe传递包含要远程执行的命令的本地文件:
def command = "C:/path/to/putty.exe -ssh user@IP -pw pass-m C:/temp/commandsToRunRemotely.text" 
def proc = command.execute() 
proc.waitFor() 

请注意,如果您的Windows路径中包含 putty.exe,则只需使用 putty.exe而不是完整路径即可。

这只是一个ilustation示例,但是如果要远程执行Shell脚本而不是在命令文件中执行 echo "test remote execution" > /tmp/myfile.txt,请直接使用脚本的路径: /home/test.sh
我从此 nice answer获得Putty命令行选项

希望能帮助到你,


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!