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
Hi,
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…)
I don’t know about that “old dos door game”, does it read from
stdin certainly?
while true
puts ("loop...")
if select([pipe],nil,nil,0.1) !=nil
Separating select call would not be nice.
while ios = select([pipe, @socket])
r, * = ios
if r.include?(pipe)
char = pipe.getc
puts "char: #{char}"
@socket.write ?\r if char == LF
@socket.write(char.chr)
end
if r.include?(@socket)
puts "socket hit"
char = @socket.getc
puts char.chr
pipe.putc(char.chr) if char
end
end
···
At Fri, 16 May 2003 09:55:55 +0900, nedry wrote:
–
Nobu Nakada
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