Through Python's subprocess module, I'm trying to capture the output of the dd command. Here's the snippet of code:
r = subprocess.check_output(['dd', 'if=/Users/jason/Desktop/test.cpp', 'of=/Users/jason/Desktop/test.out'])
however, when I do something like
print r
I get a blank line.
Is there a way to capture the output of the dd command into some sort of data structure so that I can access it later?
What I essentially want is to have the output below be stored into a list so that I can later do operations on say the number of bytes.
1+0 records in
1+0 records out
4096 bytes transferred in 0.000409 secs (10011579 bytes/sec)
dd
does not output anything to stdout, so your result is correct. However, it does output to stderr. Pass instderr=subprocess.STDOUT
to get the stderr output: