Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用soapUI执行shell脚本_Shell_Groovy_Soapui - Fatal编程技术网

如何使用soapUI执行shell脚本

如何使用soapUI执行shell脚本,shell,groovy,soapui,Shell,Groovy,Soapui,我有一个shell脚本,比如sample.sh。我想使用soapUI执行这个脚本。如何使用SOAPUI执行它???您可以使用Groovy步骤来实现这一点。比如: p = Runtime.getRuntime().exec("sample.sh") p.waitFor() 如果要以字符串形式获取结果,请执行以下操作: 窗口: def result = 'cmd /c sample.bat'.execute().text def result = 'sh -c sample.sh'.execut

我有一个shell脚本,比如sample.sh。我想使用soapUI执行这个脚本。如何使用SOAPUI执行它???

您可以使用Groovy步骤来实现这一点。比如:

p = Runtime.getRuntime().exec("sample.sh")
p.waitFor()

如果要以字符串形式获取结果,请执行以下操作:

窗口:

def result = 'cmd /c sample.bat'.execute().text
def result = 'sh -c sample.sh'.execute().text
外壳:

def result = 'cmd /c sample.bat'.execute().text
def result = 'sh -c sample.sh'.execute().text

请注意,执行文件通常需要“cmd/c”或“sh-c”部分。如果您想运行简单的内部命令,如“dir”或“ls”,那么就不需要了。

在批处理文件中,我有3行:1。“cmd/K start”+“plink.exe-sshroot@IP-密码“2。shsample.sh3。只有exit Only第一行在登录到服务器后被执行,而不是执行第二行。这显然是因为第#1行将带您进入一个新会话,其中其他行等待此会话结束以运行。有一个简单的方法可以做到这一点。看来你是在使用Windows,那么你可以用油灰作为媒介。不久前我写了一篇博客,希望能有所帮助:@SiKing,谢谢你的留言。对于shell/bash,它应该是-c。这只是说明等待执行完成。另外:
result
被分配执行的
.text
,然后执行
result.waitFor()
?!?!字符串没有waitFor()方法!