From: Luis Lavena Date: 2009-12-16T23:55:12+09:00 Subject: Re: Cannot obtain child process exit code on Windows On Dec 16, 5:32 am, Wi siong Ko wrote: > Luis Lavena wrote: > > On Dec 16, 4:18 am, Wi siong Ko wrote: > >> system('a.bat') > >> Can anyone help me? > > When reporting any issue, please include full version of Ruby (ruby - > > v) that you're using. > > > Here an example: > > > ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32] > > > irb(main):001:0> system("echo foo && exit /b 29") > > foo > > => false > > irb(main):002:0> $? > > => # > > > irb(main):001:0> $? > > => # > > irb(main):002:0> system('foo.bat') > > => false > > irb(main):003:0> $? > > => # > > > The exitstatus is correct, what are you trying to achieve shifting the > > Process:Status exitstatus value? > > Luis, > > I am using ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32]. > The right shifting was just trying with example given in > > > Following your example, the exit code is 0 if is in a batch file. Here > is my session: > > C:\>type foo.bat > exit /b 29 > > C:\>irb > irb(main):001:0> system("echo foo && exit /b 29") > foo > => false > irb(main):002:0> $? > => # > irb(main):003:0> system('foo.bat') > > C:\>exit /b 29 > => true > irb(main):004:0> $? > => # > When testing if there is a bug, please try latest patchlevels. Since you're using mswin32 installation and a really old patchlevel (zero). Will recommend migrate to RubyInstaller: http://rubyinstaller.org/ Which is the successor of One-Click Installer and provides, at this time under RC1, binaries for both 1.8.6 and 1.9.1-p243 -- Luis Lavena