Trying to strip characters out of output from the following snippit: subprocess.Popen(cmd,shell=true,stdout=subprocess.PIPE)
Longterm i need to split the output into seperate list indexes. Trying to test this with stdout output to validate that its working first. Here is a snippit of the code right now:
#!/usr/bin/env python3.4
import subprocess
def writefile():
sites = ['blue.com', 'red.com']
for site in sites:
proc = subprocess.Popen(["python dnstwist.py -g " + site + "| sed -e '1,8d' | grep -v -"],shell=True,stdout=subprocess.PIPE,universal_newlines=True)
while True:
line = proc.stdout.readline()
if line!= '':
print(line.strip('/'))
else:
break
I have also tried:
line = proc.stdout.readline().strip('/')
if line!= '':
print(line)
else:
break
output always looks like this sample. Notice the forwardslash is not being stripped out:
Replacement 4ed.com 212.48.70.37/United Kingdom MX:mail.4ed.com
Replacement r4d.com 69.172.201.208/United States
Also it looks like its adding \n or \r.
Longterm i would like it to be something i can parse out to look like the following:
{'4ed.com': ['Replacement', '212.48.70.37', 'somewhoisdata', 'United Kingdom'] }
...etc