I\'ve written a bash script that is doing exactly what I want it to do, but kicking out the following error:
close failed in file object destructor: sys.except
There are two steps you need to perform:
Step 1:
In your csvcut script, find all locations where sys.stdout.write() are called, make sure sys.stdout.flush() is called after each write().
Step 2:
With step 1 completed you should now be able to capture IOError within the Python script. Below is one example on how to handle broken pipe:
try:
function_with_sys_stdout_write_call()
except IOError as e:
# one example is broken pipe
if e.strerror.lower() == 'broken pipe':
exit(0)
raise # other real IOError
Hope it helps!