From: Xie Hanjian Date: 2008-04-20T20:40:41+09:00 Subject: Re: What's the 'portable' way to do this? --i9LlY+UWpKt15+FH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * James Tucker [2008-04-19 19:55:45 +0900]: > > On 19 Apr 2008, at 10:55, Michael Fellinger wrote: > >> On Sat, Apr 19, 2008 at 1:40 PM, Xie Hanjian wrote: >>> Hi, >>> >>> I'm afraid the problem is the same: you can't interact with the program >>> after data has been read. any function like getch() will try to read= =20 >>> input >>> from the file to which stdin was redirected instead of your console. >> >> You can check if you are getting data from a pipe by asking >> $stdin.tty? and act accordingly. >> See http://p.ramaze.net/1144 for a short example. >> >> Regarding platform compatibility, according to >> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/146259 >> you can $stdin.reopen("COM1:") > > Make that CON: and you're on to a winner! > > dev =3D 'CON:' > [$stdin, $stdout].each {|io| io.reopen(dev)} > puts gets Not works here, only on windows? Actually I find this: http://www.a-k-r.org/ruby-terminfo/rdoc/classes/TermInfo.html#M000031 Thanks all guys :-) Jan > > :-) > >> ^ manveru > > --=20 jan=3Dcallcc{|jan|jan};jan.call(jan) --i9LlY+UWpKt15+FH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkgLK0oACgkQrEeD7Z87FjrW7gCfe+UXxhkyHE/P3gPkLhmh3FeO Q8YAn2IbNm8bYWNyoQ5lkiRGbjmA6CTu =LGmi -----END PGP SIGNATURE----- --i9LlY+UWpKt15+FH--