0

I'm trying to check reverse lookup of IP address and then write the result to txt file. How I can write the result to file using regex or grep ?

My script:

import sys, os, re, shlex, urllib, subprocess 

cmd = 'dig -x %s @192.1.1.1' % sys.argv[1]

proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE)
out, err = proc.communicate()

sys.stdout = open("/tmp/test.txt", "w")
print(out)
sys.stdout.close()
OmZ
  • 31
  • 1
  • 7

0 Answers0