Search code examples
pythongroovy

How can I run a Groovy script from within a Python script?


I have a Groovy script that gives me an output file that I will use as an input file to a Python script. I want to run the Groovy script from within python instead of running Groovy and then running Python. If it is possible, please tell me how I can do it?


Solution

  • There are mainly 2 ways:

    import os
    os.system("groovy your_script.groovy")
    
    import subprocess
    subprocess.check_call(["groovy", "your_script.groovy"])