From: Jason Mayer Date: 2007-02-11T12:26:28+09:00 Subject: Re: Windows and Ruby - Not very good friends? ------=_Part_85052_19051541.1171164386165 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 2/10/07, Bharat Ruparel wrote: > > I am new to Ruby and RoR, so pardon me if I ask naive questions. > > Ruby on Windows just does not feel right to me. Primarily, I develop in > Linux, mostly in Fedora. Though, I have Ubuntu installed on some > machines as well. I do get stuck in Linux too, mostly due to my lack of > knowledge and experience with Ruby and RoR, but have much better batting > average finding my way around the problems. I have a dual boot machine > with Windows and Fedora. So I decided to go through the "Programming > Ruby" book on the Windows side just for the heck of it -- I keep running > into problems that I have no idea how to fix. > > Here is another one: > > This is a little program out of the PickAxe book (2nd Edition) on page > 108. > > opfile_name = "C:\\RubyPrograms\\PickAxeBook\\testfile" > socket = $stdin > op_file = File.open(opfile_name, "w") > begin > # Exceptions raised by this code will > # be caught by the following rescue clause > while data = socket.read(512) > op_file.write(data) > end > > rescue SystemCallError > $stderr.print "IO failed: " + $! > op_file.close > File.delete(opfile_name) > raise > end > > When I run it, a nice little DOS window opens up with > C:\ruby\bin\ruby.exe it its title bar and the cursor just waits. I > cannot type, cannot CNTRL-C, except close it by clicking on the top > right hand corner X box. When I do, ruby quits with the following > message: > > >ruby ex0261.rb > >Exit code: -1073741510 > > How does one go about debugging this? I can't even tell which line of > the code the program is hung-up at? > > I can see that windows/ruby is creating the testfile in the directory > which has zero bytes. I thought that the line socket = $stdin assigns > standard input to this input stream which we call socket. Therefore, am > I not supposed to be able to type into the Waiting DOS window that opens > up? Is this not the Standard Input? > Well... I couldn't duplicate your problem at first. I copied and pasted your code and it ran fine on my machine (after I changed the path). It even seems to have done what it was supposed to - opened the file, wrote 512 chars to it etc. (btw, how would one cause the exception to be raised? invalid characters?) Then I realized you might be trying to do it from within SciTe. try doing it from a command prompt. ------=_Part_85052_19051541.1171164386165--