Using dd command through Python's subprocess module -


through python's subprocess module, i'm trying capture output of dd command. here's snippet of code:

r = subprocess.check_output(['dd', 'if=/users/jason/desktop/test.cpp', 'of=/users/jason/desktop/test.out']) 

however, when

print r 

i blank line.

is there way capture output of dd command sort of data structure can access later?

what want have output below stored list can later operations on number of bytes.

1+0 records in 1+0 records out 4096 bytes transferred in 0.000409 secs (10011579 bytes/sec) 

dd not output stdout, result correct. however, output stderr. pass in stderr=subprocess.stdout stderr output:

>>> o = subprocess.check_output(     ['dd', 'if=/etc/resolv.conf', 'of=r'], stderr=subprocess.stdout) >>> print(o) b'0+1 records in\n0+1 records out\n110 bytes (110 b) copied, 0.00019216 s, 572 kb/s\n' 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -