Forum Discussion

writer's avatar
writer
New Contributor
15 years ago

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

  • JHunt's avatar
    JHunt
    Community Hero

    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!
  • writer's avatar
    writer
    New Contributor
    Does anyone know how to execute a bat file from within a Goovy script Test Step in SoapUI?
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    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
  • 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();