cancel
Showing results for 
Search instead for 
Did you mean: 

Run a batch file from Groovy Script

smadden
New Contributor

Run a batch file from Groovy Script

I have a batch file that sorts a pipe delimited file. I put the batch file at the project level directory. I then put the following in a Groovy Script:

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

 

I receive the following error: java.io.IOException: Cannot run program "test1.bat": CreateProcess error=2, The system cannot find the file specified error at line: 1

 

Something else I need to do to get it to find the file that is ACTUALLY there? 

 

5 REPLIES 5
nmrao
Community Hero

Re: Run a batch file from Groovy Script

May be you can try with absolute path (use path separator unix style).
for example
Runtime.runtime.exec("cmd /c c:/Users/apps/test.bat")


Regards,
Rao.
kbw
Contributor

Re: Run a batch file from Groovy Script

You've probably found your answer by now, but just in case anyone else runs into this, here's how you can reference a file relative to your SoapUI project's location:

 

 

// Path of a file, relative to current project
def filePath = groovyUtils.projectPath + '/somefolder/somefile.txt';

 

ElChien23
New Contributor

Re: Run a batch file from Groovy Script

How would I launch a batch if I were running SOAP UI locally, and my tests were hitting a remote machine?  The batch would be on the remote machine as well.  Any ideas how I could launch that batch?  

 

Thanks!

kbw
Contributor

Re: Run a batch file from Groovy Script

Hmmm... Running a batch file on a remote computer is a different beast.  I've never needed to look into that.

 

I recommend creating a separate thread for that question, if it hasn't already been asked.  It is different than this question, and you'll get more eyes on it as its own thread.

Ranjeeth_Raj
New Contributor

Re: Run a batch file from Groovy Script

I am also facing issue in .bat file execution in SoapUI using groovy.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors