cs p
cs p

Reputation: 13

To convert a pcap file to a json file(tshark)

It works normally in the cmd window, but does not work in Python software The json file is empty when you write the code below. json file is empty to be created.

"cmd) tshark –r 15_20.pcap –T json >15_20.json" It works normally.

import os, sys
import subprocess

#os.system('tshark –r 15_20.pcap –T json > /15_20.json')
subprocess.run('tshark –r 15_20.pcap –T json > 15_20.json' ,shell=True)

Upvotes: 1

Views: 2794

Answers (1)

Vaibhav Singh
Vaibhav Singh

Reputation: 26

The following code works normally -

import os
os.system('tshark -r check.pcap -T json > file.json')

I am seeing that the JSON content gets saved in file.json.

I tried it on my MAC terminal. Can you provide more details on the issue you are facing? Do you specifically want to use subprocess?

Upvotes: 1

Related Questions