@AnttiHaapala i mistyped the last post. I'm using
subprocess.check_output(cmd,shell=True)
tail: write error: Broken pipe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'tail --line=+4181 /my/file | head --lines=222 | egrep --regexp="STRING"' returned non-zero exit status 1