Lo HaBuyshan
Lo HaBuyshan

Reputation: 369

In Ruby, how do I redirect STDIN to a file

This Ruby code hangs:

file = File.open('filename')
STDIN = file
do_stuff
file.close

So in Ruby, how do I redirect STDIN to a file?

Upvotes: 0

Views: 209

Answers (1)

Lo HaBuyshan
Lo HaBuyshan

Reputation: 369

Ok, based on the variation link provided, I got it to work:

file = STDIN.reopen('filename')
do_stuff
file.close

Thanks!

Upvotes: 1

Related Questions