This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

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:')[1] 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

Googlesomething's gravatar image

Googlesomething
11114
accept rate: 0%

edited 27 Jul '15, 08:48

cmaynard's gravatar image

cmaynard ♦♦
9.3k1038142


Dumpcap writes the filename to stderr, not stdout.

permanent link

answered 27 Jul '15, 08:46

cmaynard's gravatar image

cmaynard ♦♦
9.3k1038142
accept rate: 20%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×154
×89
×26

question asked: 27 Jul '15, 08:29

question was seen: 1,559 times

last updated: 27 Jul '15, 08:48

p​o​w​e​r​e​d by O​S​Q​A