From: Guillaume Marcais Date: 2003-05-16T10:58:31+09:00 Subject: Re: another popen question...the ruby bbs You probably need to flush your data after writing or change the sync flag of your IO stream. Unlike stdout, the pipe is not flushed after a "\n". Guillaume. Le jeudi, 15 mai 2003, � 20:55 US/Eastern, nedry a �crit : > All this talk of popen put me in mind of something. I could use it to > link the Ruby BBS to external programs, specifically all those old dos > door games by using dosemu and redirecting the output... > > I got it to get the data from the application ok, but I can't figure > out how to get data to the application.... nothing seems to be > happening when I write data to the external process... any ideas, > advice, boots to the head would be appreciated (keeping in mind that > it is now 2am...) > > def doortest > > begin > pipe = IO.popen("./dosemu,"w+") > while true > puts ("loop...") > if select([pipe],nil,nil,0.1) !=nil > char = pipe.getc > > puts "char: #{char}" > #if char != nil > @socket.write (char.chr) > @socket.write CR.chr if char == LF > else > if select([@socket],nil,nil,0.1) != nil > puts "socket hit" > > char = @socket.getc > puts char.chr > pipe.putc(char.chr) if char != nil > > end > end > end > rescue > print ("\r\nDisconnected from Application...\r\n") > pipe.close > end > end > > > Thanks! > > Mark Firestone >