I am currently trying to parse the filename from dumpcap's stdout in order to set it to a variable within my python script.
def startdump(): global DUMPCAP #global dumpdirectory global eventfile setDumpcapOptions() # Function that sets DUMPCAP = dumpcap -b duration:2147483647 -c 100 -i 1 -n -p -s 2 -w test3 -B 20 print("dumpcap.exe = " + DUMPCAP) #os.chdir(dumpdirectory) proc1 = subprocess.Popen(DUMPCAP, shell=True, stdout=subprocess.PIPE) if dc_mode == "Dumpcap Only": time.sleep(5) with open("proc1stdout.txt", 'w+') as proc1stdout: proc1stdout.write(str(proc1.stdout)) for line in proc1stdout: print("%s" % line) if "File:" in line: print(line) eventfile = line.split('File:') print(eventfile) mail_man() proc1.communicate()
This gives me an error
[Errno 2] No such file or directory: ''
I am coding in Python2.6.6. The Popen module does not support iterating so I cannot parse directly from the stdout in the terminal. Is there a way to write the Dumpcap stdout to a text file so that I can much more easily parse it from there?
asked 27 Jul '15, 08:29
accept rate: 0%
edited 27 Jul '15, 08:48