title: How to execute a Groovy Script from my Grails app?
body: <p>Well, it seems a simple task but I didn't manage to make it run.</p>
  
  <p>I have a groovy script that runs fine under Windows Vista when calling from prompt:</p>
  
  <pre><code>&gt; cd MY_GAILS_PROJECT_DIR
  &gt; groovy cp src/groovy scripts/myscript.groovy
  </code></pre>
  
  <p>Now, I want to execute this script (and passing to it some input arguments) through my my Maintenance Service Class (called from a controller) as below,</p>
  
  <pre><code>class MaintenanceService {
    def executeMyScript() {
      "groovy cp src/groovy scripts/myscript.groovy".execute()
    }
  }
  </code></pre>
  
  <p>It does not work at all! I don't even manage to have the execute() method recognizing any command (like <code>"cd .".execute()</code>) throwing exception:</p>
  
  <pre><code>Error 500: java.io.IOException: Cannot run program "cd": CreateProcess error=2, The system cannot find the file specified
  </code></pre>
  
  <p>1- How can I execute a groovy script from my grails application? </p>
  
  <p>2- What are the best practices here? For instance, should I use the QuartzPlugin and then the triggerNow method for executing a script? should I use a Gant Task? If yes, how to do it?</p>
  
  <p>Thank you.</p>