linux - Problem with Ruby script output being stored into a file -


I have a Ruby script that creates a heap of text. As an example:

  puts "line 1" puts "line 2" puts "line 3" # etc ... (obviously, how does this work my script ..)  

Data is not too - Probably a total of 8kb character figures in the total.

When I run the script on the command line, the expected work:

  $ ./my-script.rb line 1 line 2 line 3  

However, when I put it in a file, the output is actually reduced to 4096 bytes:

  $ ./my-script.rb> gt; ; Output.txt  

What to stop at 4kb?

Update: I just have to print the script directly to the file instead of printing it on the screen and capturing the output, and the problem is still happening. !

  $ output = file.new ("file.txt") $ output & lt; & Lt; "Line 1" #tc ..  

Is your program ending correctly ? The OS can be internal buffer size for 4kB I / O, and the data present in the following buffer (up to 8kB which is the total size of your data) is lost when your program ends suddenly or does not end at all < / P>


Comments