| 12345678910111213141516171819202122232425262728293031323334 | #!/usr/bin/python
import os
import subprocess
import sys
import tempfile
def stdin_chunk(chunksize):
    while True:
        chunk = sys.stdin.read(chunksize)
        if chunk:
            yield chunk
        else:
            break
if __name__ == '__main__':
    CHUNKSIZE = 8192
    tfile, tname = tempfile.mkstemp()
    for chunk in stdin_chunk(CHUNKSIZE):
        os.write(tfile, chunk)
    os.close(tfile)
    p = subprocess.Popen(["file", tname], stdout=subprocess.PIPE)
    stdout, stderr = p.communicate()
    os.unlink(tname)
    if stderr:
        sys.stderr.write(stderr)
        sys.exit(1)
    else:
        sys.stdout.write(stdout)
 |