Skip to content

Instantly share code, notes, and snippets.

@rosenhouse
Forked from hikoz/dd.py
Created May 14, 2014 06:47
Show Gist options
  • Save rosenhouse/d2586862d0179a331483 to your computer and use it in GitHub Desktop.
Save rosenhouse/d2586862d0179a331483 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import time
import signal
from subprocess import Popen, PIPE
dd = Popen(['dd'] + sys.argv[1:], stderr=PIPE)
while dd.poll() is None:
time.sleep(.3)
dd.send_signal(signal.SIGUSR1)
while 1:
l = dd.stderr.readline()
if 'records in' in l:
print l[:l.index('+')], 'records',
if 'bytes' in l:
print l.strip(), '\r',
break
print dd.stderr.read(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment