From: Dave Burns Date: 2008-03-14T09:30:03+09:00 Subject: Re: script runs ok alone, broken pipe when piped to head? On Mar 13, 1:04 pm, Mark Bush wrote: > Dave Burns wrote: > > so I piped it to head and it bombs: > > > ruby -rubygems excelparse.rb stuff.xls|head > > Row: 0 Cell: 0> Dispapp > > Row: 0 Cell: 1> Iprc > > Row: 0 Cell: 2> UH tag > > Row: 0 Cell: 3> Weight > > Row: 0 Cell: 4> Tags removed > > Row: 0 Cell: 5> Disk removed or wiped > > Row: 1 Cell: 0> 80118 > > Row: 1 Cell: 1> 1173 > > Row: 1 Cell: 2> 961SU > > Row: 2 Cell: 0> 80118 > > excelparse.rb:19:in `write': Broken pipe (Errno::EPIPE) > > The "head" command reads and prints the first 10 lines of input (by > default), then closes its input and exits. > > Your script is thus having it's output stream closed which it isn't > expecting. The broken pipe is to be expected. > So to get my script to act like a responsible command line citizen, I'd need to insert some error handling and return normally when the pipe breaks, right? Thanks for the info. Dave