From: Xie Hanjian Date: 2008-04-19T13:40:23+09:00 Subject: Re: What's the 'portable' way to do this? --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 input =66rom the file to which stdin was redirected instead of your console. Thanks Jan * Daniel Finnie [2008-04-19 02:08:11 +0900]: > Hi, >=20 > I think ARGF might work for your needs: >=20 > data =3D ARGF.read >=20 > Give it a try, > Dan >=20 > On 4/17/08, Xie Hanjian wrote: > > Hi, > > > > I want to know if there's a more 'portable' way to do this in ruby: > > > > I hope my programe will accept data from redirected stdin or pipe, like > > > > cat bar | foo.rb > > foo.rb < bar > > > > And after read the data I want to interact with the foo.rb in console. > > The problem is stdin has been redirected so I have to: > > > > STDIN.reopen('/dev/tty') > > > > Hardcoding a string in the script seems not good. Any suggestions? > > > > Thanks > > Jan > > > > > > -- > > jan=3Dcallcc{|jan|jan};jan.call(jan) > > > > >=20 --=20 jan=3Dcallcc{|jan|jan};jan.call(jan) --pf9I7BMVVzbSWLtt Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkgJd1YACgkQrEeD7Z87FjqPDACggDLuwnpdAo8JQ7/0C5ibBzbP GbUAn347pSLqeXEQD2OGho/wlgRJemBR =lnZx -----END PGP SIGNATURE----- --pf9I7BMVVzbSWLtt--