Thanks, but flushing won’ t help. Something like this does not work.
the program hangs, when trying the second write.
…
if (ke != nil)
ke.syswrite(loginCall)
ke.flush()
ke.each(“\n”) { |line| puts(line) }
# we get until here
# this does not get through
ke.syswrite(sysInfoCall)
ke.flush()
# we never get here – program hangs !!
ke.close_write
ke.each(“\n”) { |line| puts(line) }
ke.close
end
My problem is, that the standard Ruby IO class seems not to allow this
type of repeated bidirectional communication dialog with another
process. Something like ke = IO.popen(“ke.exe”, “r+”) would give me a
bidirectional communication channel, but unfortunatly it is not
possible to read from the I/O stream until the write end of the I/O
stream is closed.
Remember to flush after writing. Or, set the IO to auto-flush.
– Dossy
–
Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)
FreeMail in der Premiumversion! Mit mehr Speicher, mehr Leistung, mehr
Erlebnis und mehr Pramie. Jetzt unter WEB.DE Club - Login
Thanks, but flushing won’ t help. Something like this does not work.
the program hangs, when trying the second write.
…
if (ke != nil)
ke.syswrite(loginCall)
ke.flush()
ke.each(“\n”) { |line| puts(line) }
# we get until here
# this does not get through
Right, because the #each will iterate until the remote side closes
their end. What you need to do is read only as many lines as you
need or expect or read until a certain string is received, or
what have you.
If you’re going to use EOF to signal “end of transmission” then
that’s what you’ll have to use, but then you can’t continue to
send and receive like you want. You need to designate some kind
of EOT (end of transmission) sequence so you can keep the connection
open.
ke.syswrite(sysInfoCall)
ke.flush()
# we never get here -- program hangs !!
ke.close_write
ke.each("\n") { |line| puts(line) }
ke.close
–
Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
“He realized the fastest way to change is to laugh at your own
folly – then you can let go and quickly move on.” (p. 70)