System & changes to ENV on Windows


(Morris, Chris) #1

If I as an ordinary Ruby user, want to use something newer than
1.6.7, what should I try ?

You can also try this Ruby replacement for system within 1.6.7, I know it
fixes other system call problems, not exactly sure if it fixes your specific
issue:

code by Hee-Sob Park - posted here:

http://ruby-talk.com/10006

def system(command)
Win32API.new(“crtdll”, “system”, [‘P’], ‘L’).Call(command)
end

code by Hee-Sob Park - posted here:

http://ruby-talk.com/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