title: Groovy script to run grails command
body: <p>I wanted to create a groovy script to run grails clean, grails compile and grails run-app, However, I noticed that I cannot run any of the grails commands. In fact then I tried to run the following script on the Groovy Console:</p>
  
  <pre><code> def envs = System.getenv().collect{"$it.key=$it.value"}
      //println envs
      println "java -version".execute(envs, new File("c:\\")).err.text
      println "grails -version".execute(envs, new File("c:\\")).text
  </code></pre>
  
  <p>This itself gives me the following output:</p>
  
  <pre><code>groovy&gt; def envs = System.getenv().collect{"$it.key=$it.value"} 
  groovy&gt; //println envs 
  groovy&gt; println "java -version".execute(envs, new File("c:\\")).err.text 
  groovy&gt; println "grails -version".execute(envs, new File("c:\\")).text 
  
  
      java version "1.7.0_06"
      Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
      Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)
  
      Exception thrown
  
      java.io.IOException: Cannot run program "grails" (in directory "c:\"): CreateProcess error=2, The system cannot find the file specified
  
          at ConsoleScript26.run(ConsoleScript26:4)
  
      Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
  
          ... 1 more
  </code></pre>
  
  <p>Has anyone faced this problem before?</p>