From: "Morris, Chris" Date: 2002-06-01T04:07:38+09:00 Subject: RE: "system" and Windows > I have cut & paste the code in my program and it doesn't work :-< > (in fact now, no command work :-<) Here it is again copied from the very file I use. Maybe the web rendition messed up some of the characters (I know it doesn't render backslashes \ correctly for me): # code by Hee-Sob Park - posted here: # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/10006 def system(command) Win32API.new("crtdll", "system", ['P'], 'L').Call(command) end # code by Hee-Sob Park - posted here: # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/10006 def `(command) popen = Win32API.new("crtdll", "_popen", ['P','P'], 'L') pclose = Win32API.new("crtdll", "_pclose", ['L'], 'L') fread = Win32API.new("crtdll", "fread", ['P','L','L','L'], 'L') feof = Win32API.new("crtdll", "feof", ['L'], 'L') saved_stdout = $stdout.clone psBuffer = " " * 128 rBuffer = "" f = popen.Call(command,"r") while feof.Call( f )==0 l = fread.Call( psBuffer,1,128,f ) rBuffer += psBuffer[0..l] end pclose.Call f $stdout.reopen(saved_stdout) rBuffer end