[prev in list] [next in list] [prev in thread] [next in thread]
List: groovy-user
Subject: Re: [groovy-user] lightweight groovy scripts?
From: "Kevin J. Slater" <kslater () pobox ! com>
Date: 2005-08-30 10:30:10
Message-ID: 1174.10.7.7.114.1125397810.squirrel () 10 ! 7 ! 7 ! 114
[Download RAW message or body]
Thanks for that Maurice. I may use your example. My main concern, and the
reason I asked for a lightweight solution, was that I need to run Groovy
from a crontab job. At present, I've borrowed my .bash_profile and used
that to create a shell script that calls my Groovy script.
...Kevin
Maurice Diamantini said:
>
> Le 29 août 05 à 19:52, Kevin J. Slater a écrit :
>
>> Ok, I tried that, and was hoping to be able to run something like the
>> helloWorld.groovy sample program:
>>
>> #!/usr/bin/env groovy
>> println("Hello world")
>> for (a in this.args) {
>> println("Argument: " + a)
>> }
>>
>> But if I invoke it with:
>>
>> java org.codehaus.groovy.tools.GroovyStarter helloWorld.groovy
>>
>> I get:
>>
>> Exception in thread "main" java.lang.NoSuchMethodError: main
>
>
> What I use is a shell script (called jorlab but could be called groovy)
> It is based on the groovy shell script provided with the groovy
> distribution.
>
> Here is an extract :
>
> CLASSPATH=.../groovy-all-1.0-jsr-03.jar:/.../commons-
> cli-1.0.jar:..MAIN_CLASS=groovy.lang.GroovyShell
> MAIN_CLASS=groovy.lang.GroovyShell
> ...
> cmd='java ${JAVA_FLAGS} ${MAIN_CLASS} ${1+"$@"}'
> eval "echo cmd=$cmd"
> eval $cmd
>
>
>
> Then, if your hello script is in your path (and it is made executable
> with chmod on unix),
> you can do a simple :
>
> helloWorld.groovy
>
> The trace give me :
> cmd=java -enableassertions -Xms10m -Xmx256m
> groovy.lang.GroovyShell ./hello.groovy
>
> And the result is :
> hello world
>
> I hope this can help,
>
> -- Maurice
>
> P.S I use macosx (unix bsd)
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic