[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-user
Subject:    RE: [groovy-user] Getting the exit status of another Groovy script
From:       "Antti Karanta" <antti.karanta () napa ! fi>
Date:       2005-08-22 13:08:55
Message-ID: 680FA370A36D83439E177BDC02F0E8B599235B () nw60 ! napa ! fi
[Download RAW message or body]


> On 22/08/05, Dierk Koenig <dierk.koenig@canoo.com> wrote:
> > it seems that ant.execute() returns a proper resultvalue
> > in the resultproperty... (but don't take my word for it)
> 
> So that's worth having a look at Ant's source code to see 
> what the magic is ;-)
> 
> Antti, did you create a JIRA issue for that execute problem?

  No. Which is the issue here - not being able to start another groovy
process by
"groovy myscript.groovy".execute()
  or "cmd /c groovy myscript.groovy".execute() giving the wrong exit
code?

  In the latter case the exit code may be right - I don't know what cmd
is supposed to return when it exits. 

  And as for the first, I don't know whether executing the string given
there as an external is even supposed to be possible in Java (meaning
are you supposed to use the form "cmd /c groovy myscript.groovy" for
some reason?), and if it's not, if Groovy is to work differently here?

  Judging by this example (requires that you have ruby interpreter
installed) the problem is not groovy getting the return values wrong:

C:\Temp>groovy -e "def p=\"ruby -e
'exit(-1)'\".execute();p.waitFor();println p.exitValue()"
-1

  So the problem is not being able to execute "groovy
myscript.groovy".execute(). I think it may have something to do w/ ruby
interpreter being an executable (.exe), but groovy being a .bat file.
So, java.lang.Process may be visioned as running binary executables and
if you want to run a batch file (or a shell script or whatever) you must
use the corresponding shell (binary) executable to run your script (the
groovy.bat - file is a script, not a binary executable). This seems to
result in the loss of the real exit code. Like you said, it's not a
groovy issue. 


  Summa summarum: I don't think there is an issue to raise.



      -Antti-




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic