Forum Discussion

zsousa's avatar
8 years ago

Can Groovy run an extral program

I have a third part executable that accepts parameters. I want to call this program and pass in those parameters through Groovy. but its not executing the file.


I found this cool utility called "node-csvtojson" it accepts a csv file and returns a nice thirft/json string like so



I tried running this from Groovy but nothing happens. so then I created a .sh file that contains the following

#! /bin/sh

csvtojson csvdata_csv.csv


and I tried calling that from Groovy and nothing happened. 


Then I installed Groovy outside of SoapUI and tried running the script and that worked.





12 Replies

  • nmrao's avatar
    Champion Level 3

    Yes, groovy can run an external program.


    Here is the script:


    String command = "cmd /c csvtojson C:/Temp/mydata.csv"
    Process child = Runtime.getRuntime().exec(command)
    InputStream in1 = child.getInputStream()
    def json = in1.text
    child.waitFor() json

  • nmrao's avatar
    Champion Level 3
    Glad know about node plugin to transfrom csv to json.