Running JRuby scripts from Windows .bat files

foo.rb contains:
puts “in foo”

foo.bat contains
@echo off
echo hello
jruby foo.rb
echo world

Running “foo” from a Windows command prompt outputs:
hello
in foo

Why doesn’t it output “world”? jruby is causing foo.bat to exit before
the last echo runs.


Mark V.

On Thu, Apr 30, 2009 at 2:37 PM, Mark V. [email protected] wrote:

hello
in foo

Why doesn’t it output “world”? jruby is causing foo.bat to exit before the
last echo runs.

Seems like the way we wrote jruby.bat is causing it to do that. Try it
with “call jruby foo.rb” instead.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Mark V. wrote:

hello
in foo

Why doesn’t it output “world”? jruby is causing foo.bat to exit before
the last echo runs.

It’s a windows batch file … “feature”. jruby is a batch file too,
and batch files calling other batch files (like you are, there),
TRANSFER control to the called batch file. They don’t call it like a
subroutine or a function and return to the caller.

Like Nick also said, you can do “call jruby foo.rb” which should solve
it for you.

From windows command prompt, “call /?” will give you a bunch of
information on different things you can do with “call”.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs