mysql - python extract fields from os.system std out -
pretty new python. i'm trying integrate github project (https://github.com/elceef/dnstwist) more dynamic / automated tool periodically execute, new domains have popped up, add them mysql database , shoot off email notify new domain needs investigated. i'm still in stages of getting work. here code far:
import os bleh = [] def writefile(): sites = ['hi.com', 'ho.com'] site in sites: bleh.append(os.system("python dnstwist.py " + site + " | sed -e '1,8d' | grep -v -")) print bleh writefile() right i'm trying figure out how take output
os.system("python dnstwist.py " + site + " | sed -e '1,8d' | grep -v -") which outputs like:
original* hi.com 205.178.189.129 bitsquatting ii.com ns:queens1.tink.com mx:mxin.mxes.net bitsquatting ji.com 198.148.92.53 bitsquatting li.com 168.63.6.189 mx:mail.li.com bitsquatting xi.com 94.56.83.199 mx:mailstore1.secureserver.net bitsquatting hh.com 38.75.9.218 mx:mailserv.hh.com bitsquatting hk.com ns:f.udrtld.net bitsquatting ha.com 206.123.52.10 mx:ironport.heritagecoin.com bitsquatting hy.com 121.40.153.241 mx:mxbiz1.qq.com homoglyph h1.com ns:ns1.sgi.net homoglyph hl.com 64.106.211.22 mx:mail1.hl.com repetition hii.com 104.209.45.42 mx:joy1.efwmx.net repetition hhi.com 64.71.33.90 mx:mail.hhi.com replacement ui.com 38.102.228.152 mx:smtp.secureserver.net replacement ni.com 96.45.82.97 mx:skprod2.natinst.com replacement bi.com 216.46.183.219 replacement gi.com 144.188.20.66 mx:motorola.com.s5a1.psmtp.com replacement yi.com 184.168.221.104 replacement h9.com 99.192.229.56 mx:h9.com replacement ho.com 69.172.201.208 replacement hj.com 198.148.92.53 replacement hu.com 83.222.226.95 mx: replacement h8.com 107.20.188.160 mx:westgate.dejan.net transposition ih.com 173.244.177.114 original* 123.com 69.58.188.49 mx:mail.entelchile.net bitsquatting 023.com 75.126.6.168 mx:mail.023.com bitsquatting 323.com 220.181.57.217 bitsquatting 523.com 198.148.92.48 bitsquatting 923.com 121.199.16.140 bitsquatting q23.com 198.148.92.62 bitsquatting 103.com ns:dns6.iidns.com bitsquatting 163.com 123.58.180.8 mx:163mx03.mxmail.netease.com bitsquatting 1r3.com ns:f1g1ns2.dnspod.net bitsquatting 122.com 219.232.254.201 mx:mxbiz1.qq.com bitsquatting 121.com 124.16.31.159 bitsquatting 127.com 123.58.180.8 bitsquatting 12s.com 5.22.149.135 mx:mx2.emailsrvr.com insertion 1323.com ns:vip2.360dns.net insertion 1233.com 198.148.92.49 insertion 1w23.com ns:ns4.51dns.com insertion 12w3.com 85.13.215.50 insertion 1q23.com 121.199.54.199 insertion 12q3.com 184.168.221.53 mx:smtp.secureserver.net insertion 1123.com 116.211.121.191 mx:mxbiz2.qq.com insertion 1213.com ns:ns0.netergy.com mx:mx0.forwarding.anynames.com replacement 223.com 198.44.249.20 replacement 1w3.com 50.22.11.28 mx:1w3.com replacement 1q3.com 184.168.221.96 mx:mailstore1.secureserver.net and take each line individually pull fields out , insert them database. know how awk, learn how python instead. method/function can use on output extract fields on each line? right line:
bleh.append(os.system("python dnstwist.py " + site + " | sed -e '1,8d' | grep -v -")) is returning [0, 0] in list.
output of os.system connected stdout. should use
os.popen("python dnstwist.py " + site + " | sed -e '1,8d' | grep -v -").read() instead of
os.system("python dnstwist.py " + site + " | sed -e '1,8d' | grep -v -") or use subprocess module. example code
import subprocess output = subprocess.check_output("python dnstwist.py " + site + " | sed -e '1,8d' | grep -v -", shell=true)
Comments
Post a Comment