Is there a synchronized exec in ruby? I try the following code and when I open the file I get nothing, and it’s probably because exec doesn’t finish writing the file.
exec "sort data.txt > data.sort"
File.foreach("data.sort") { |line| puts line}
Ted
You were looking for
system, notexec. However, it’s a lot easier than that if you use backticks, which return the output of the command.If you need to iterate, then you can iterate over the return value directly:
or even: