I have a simple ruby script that looks like this
during line " Csv 'is required = STDIN.gets array = CSV.parse_line (line) puts array [2] termination
But when I use this script in this way in the Unix pipeline If I try to, I get output of 10 lines, after an error:
ruby lib / myscript.rb
Is there a way to write Ruby script in such a way that prevents broken pipes from being lifted?
head
shutting down the standard output stream after reading all the data Is it needed. You should handle the exception and stop writing standard output. After the standard output is closed, the following code will end loop:
while line = STDIN.gets array = CSV.from_line (line) starts array [2] Rescue Errno :: EPIPE break end and
Comments
Post a Comment