cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute a bat file from within a groovy script Test Step

New Contributor

How to execute a bat file from within a groovy script Test Step

From a groovy script Test Step in the soapUI application, how can you execute a bat file?
4 REPLIES 4
New Contributor

Re: How to execute a bat file from within a groovy script Test Step

Does anyone know how to execute a bat file from within a Goovy script Test Step in SoapUI?

Re: How to execute a bat file from within a groovy script Test Step

Hello,

You should be able to execute it from Groovy by running something along the lines of:


Runtime.runtime.exec("file.bat")


Regards,
Dain
eviware support

Join the annual community event and share your stories to win gifts
Wintertainment2019
New Contributor

Re: How to execute a bat file from within a groovy script Test Step

I am trying to execute .bat file from SoapUI using groovy.

Scrip is executing successfully but bat file is not executed, I am using both type as below both are not working

 

  1. Runtime.runtime.exec("cmd /c C:\\My_docs\\Soap_UI_Report\\Data\\release_template\\extract.bat");
  2. def proc = "cmd /c C:/My_docs/Soap_UI_Report/Data/release_template/extract.bat".execute();
Highlighted
Community Hero

Re: How to execute a bat file from within a groovy script Test Step

How are you determining whether it is running or not? By default, just calling exec or execute only returns a Process so you need to do something with that Process. There is no command prompt window shown.

 

Below is a way to see the output:

 

String line
def p = "cmd /c C:\\temp\\hw.bat".execute()
def bri = new BufferedReader (new InputStreamReader(p.getInputStream()))
while ((line = bri.readLine()) != null) {log.info line}
INFO:C:\Program Files\SmartBear\SoapUI-5.4.0\bin>echo Hello World!

INFO:Hello World!