I'd like to use os.system("md5sum myFile")
and have the result returned from os.system instead of just runned in a subshell where it's echoed.
In short I'd like to do this:
resultMD5 = os.system("md5sum myFile")
And only have the md5sum in resultMD5 and not echoed.
subprocess
is better than using os.system
or os.popen
import subprocess
resultMD5 = subprocess.Popen(["md5sum","myFile"],stdout=subprocess.PIPE).communicate()[0]
Or just calculate the md5sum yourself with the hashlib
module.
import hashlib
resultMD5 = hashlib.md5(open("myFile").read()).hexdigest()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With