How to get the ruby.exe Return Code in CMD Bat?

Posted by amw_jjj on Stack Overflow See other posts from Stack Overflow or by amw_jjj
Published on 2014-08-25T04:04:46Z Indexed on 2014/08/25 4:20 UTC
Read the original article Hit count: 130

Filed under:
|
|
|

I'm trying to get the return value of a ruby script in cmd.exe. The ruby script will return -1 if exception is caught and 0 if success.

rescue Exception => ex
  puts ex.message
  returnvalue = -1
else
  returnvalue = 0
ensure
  puts returnvalue

in the cmd batch, calling the script using ruby.exe

ruby tt.rb 1 %1

But I'm not able to retreive the returnvalue in the cmd batch file (e.g. using %errorlevel%). Is there any way to do this?

thanks!

© Stack Overflow or respective owner

Related posts about ruby

Related posts about Windows