0

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?

Lo HaBuyshan
  • 359
  • 2
  • 12
  • Some variation of https://stackoverflow.com/questions/3018595/how-do-i-redirect-stderr-and-stdout-to-file-for-a-ruby-script ? – Brad Werth Nov 20 '17 at 23:42

1 Answers1

1

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

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

Thanks!

Lo HaBuyshan
  • 359
  • 2
  • 12