From: x1 Date: 2005-09-09T10:09:18+09:00 Subject: Re: Problem with popen on windows ------=_Part_50_3018462.1126228154186 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I second this and have battled it numerous times. Finally, I've just given= =20 up on it and execute the job with ruby.exe, and let a dos prompt sit there= =20 ignorantly. I've been sitting here hopelessly PRAYING that a fix for this will be=20 provided with ruby2. *waits impatiently. On 9/8/05, stevetuckner wrote: >=20 > Kroeger Simon (ext) wrote: >=20 > >Hi all, > > > >i'm using ruby 1.8.2 (2004-12-25) [i386-mswin32] on win2000. > > > >When starting my GUI app with rubyw (because i don't like the empty > >window) there is another window poping up whenever i call popen. (or use > >backquotes to start another process) > > > >Using just ruby.exe all seems fine (except the initial nasty empty > >window) > > > >Someone knows a way around? > > > >cheers > > > >Simon > > > > > > > > > > > Below was my attempt to say, here is how you should fix this issue. And > then it didn't work. If I run it with ruby it works fine. When I run it > with rubyw, it just goes away when I click run. Any ideas anyone? The > system code and `` code is taken from the list a long time ago. >=20 > Steve Tuckner >=20 > --------------------------------------------- > require "vr/vruby" > require "vr/vrcontrol" > require 'Win32API' >=20 > def system(command) > Win32API.new("crtdll", "system", ['P'], 'L').Call(command) > end >=20 > def `(command) > popen =3D Win32API.new("crtdll", "_popen", ['P','P'], 'L') > pclose =3D Win32API.new("crtdll", "_pclose", ['L'], 'L') > fread =3D Win32API.new("crtdll", "fread", ['P','L','L','L'], 'L') > feof =3D Win32API.new("crtdll", "feof", ['L'], 'L') > saved_stdout =3D $stdout.clone > psBuffer =3D " " * 128 > rBuffer =3D "" > f =3D popen.Call(command,"r") > while feof.Call( f )=3D=3D0 > l =3D fread.Call( psBuffer,1,128,f ) > rBuffer +=3D psBuffer[0..l] > end > pclose.Call f > $stdout.reopen(saved_stdout) > rBuffer > end >=20 > class MyForm < VRForm >=20 > def construct > addControl VRButton, "run", "run", 0, 0, 150, 40 > move 0, 0, 160, 73 > end >=20 > def run_clicked > messageBox(`dir`) > end > end >=20 > VRLocalScreen.showForm MyForm > VRLocalScreen.messageloop >=20 >=20 >=20 > ------=_Part_50_3018462.1126228154186--