From: Luis Lavena Date: 2009-12-16T16:40:09+09:00 Subject: Re: Cannot obtain child process exit code on Windows On Dec 16, 4:18 am, Wi siong Ko wrote: > Hi, > > I would like to obtain the exit code from a child program. But all the > methods I tried were in vain. Here are two files that i used to test. > > C:\> type a.bat > @echo off > exit /b 29 > > C:\> type test.rb > system('a.bat') > puts $? > puts $? >> 8 > exit > > C:\>ruby test.rb > pid 5952 exit 0 > 0 > > Seems like in Windows, Ruby can never see the number 29 anyway. > > 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 Lavena