Python: Closing a for loop by reading stdout
Posted
by
user1732102
on Stack Overflow
See other posts from Stack Overflow
or by user1732102
Published on 2012-10-10T03:02:04Z
Indexed on
2012/10/10
3:37 UTC
Read the original article
Hit count: 81
python
|while-loops
import os
dictionaryfile = "/root/john.txt"
pgpencryptedfile = "helloworld.txt.gpg"
array = open(dictionaryfile).readlines()
for x in array:
x = x.rstrip('\n')
newstring = "echo " + x + " | gpg --passphrase-fd 0 " + pgpencryptedfile
os.popen(newstring)
I need to create something inside the for loop that will read gpg's output. When gpg outputs this string gpg: WARNING: message was not integrity protected
, I need the loop to close and print Success!
How can I do this, and what is the reasoning behind it?
Thanks Everyone!
© Stack Overflow or respective owner