Unable To Get Result From Stdout With Subprocess
Solution 1:
i am not used to use python on windows, but try the following. Don't use shell=True
, instead try with this cmd:
cmd = ["H:/path/to/openssl.exe", "x509", "-in", "H:/path/to/cert.pem", "-noout", "-subject"]
Solution 2:
Have you tried storing the entire command as raw string and passing it with shell=True
cmd = r'H:/path/to/openssl.exe x509 -in H:/path/to/cert.pem -noout -subject'
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = p.communicate()
print(out[0]) #for std out
print(out[1]) # for std err
Edit: This worked for me with stderr,
print p.communicate()[1]
b'unable to load certificate\r\n3636:error:0D07209B:asn1 encoding routines:ASN1_
get_object:too long:./crypto/asn1/asn1_lib.c:142:\r\n3636:error:0D068066:asn1 en
coding routines:ASN1_CHECK_TLEN:bad object header:./crypto/asn1/tasn_dec.c:1281:
\r\n3636:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 erro
r:./crypto/asn1/tasn_dec.c:380:Type=X509\r\n3636:error:0906700D:PEM routines:PEM
_ASN1_read_bio:ASN1 lib:./crypto/pem/pem_oth.c:83:\r\n'
Post a Comment for "Unable To Get Result From Stdout With Subprocess"