0

I am trying to execute an editcap command inside a python script. Usually, I do it in cmd, but I want to include it in my python script.

editcap –c 10000 C:\Users\Administrator\Desktop\C_datasets\sa1.pcap C:\Users\Administrator\Desktop\C_datasets\outputs\sa1_output.pcap

Just for info, my editcap is installed with wireshark in C:\Program Files\Wireshark. –c option divides my sa1.pcap input file into subfiles having no more than 10000 packets named with the suffix sa1_output.pcap

This is not executable itself, rather including its options and parameters also.

My python script:

import os 

os.system(r' "C:\"Program Files"\Wireshark\editcap –c 10000 "D:\Datasets\Kaggle Dataset\Video\Zoom\Zoom_2.pcap" D:\zoom.pcap "')

Running the above python script in cmd throws:

editcap: The file "ΓÇôc" doesn't exist

I have absolutely no idea what this is. I can't find anything about it. Whereas running the above editcap command from cmd (without python scripting) runs perfectly.

4
  • Does this answer your question? How to execute a command prompt command from python Commented Jul 30, 2022 at 16:54
  • i have tried mostly every command but come up empty handed Commented Jul 30, 2022 at 17:15
  • Can you show your python script (or at least the part where you tried this) so that we can understand more? Commented Jul 30, 2022 at 17:24
  • ive added some more info. please check Commented Jul 30, 2022 at 18:47

1 Answer 1

0

You can use subprocess as below:

import subprocess

command = 'C:\"Program Files"\Wireshark\editcap –c 10000 "D:\Datasets\Kaggle Dataset\Video\Zoom\Zoom_2.pcap" D:\zoom.pcap'
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
process.wait()
out, err = process.communicate()

Also, make sure you are escaping the nested quotes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.