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

Convert libpcap to pdml

0

Hi all,

I am attempting to automate some capturing and conversion tasks using JAVA.

I want to capture in files with size of 1024kB using the option -b filesize:1024

I also want these raw data converted to PDML/XML. I use: tshark -r infile > outfile -T pdml; This works fine using command prompt/console, but in JAVA this '>' to redirect stdout, seems to behave badly or not at all:

Runtime.getRuntime().exec("C:\Program Files\Wireshark\tshark -T pdml -r C:\test16 >C:\test105");

The next line however works fine: Runtime.getRuntime().exec("C:\Program Files\Wireshark\tshark -r C:\test16 -w C:\test105"); So reading and writing files seems no problem.

Any suggestions to do this conversion task? Probably another program is more suitable? I saw the function of text2pcap but in fact I need this but then the other way round.

Thanks for your responses!

asked 25 Mar '11, 02:12

oty's gravatar image

oty
1112
accept rate: 0%


2 Answers:

2

That's because the ">" is handled by the command shell and not by tshark. The function Runtime.getRuntime().exec() probably just passes all arguments to the executable and not run a shell underneath. I think the best way to solve this is by having a "glue" batch file that does the redirection for you:

Runtime.getRuntime().exec("C:\convert.bat C:\test16 C:\test105");

Where convert.bat should look something like:

@echo off
C:\Program Files\Wireshark\tshark -T pdml -r %1 > %2

answered 25 Mar '11, 02:46

SYN-bit's gravatar image

SYN-bit ♦♦
17.1k957245
accept rate: 20%

0

Thanks a lot, SYNbit!

You were right, there was no shell underneath but thanks to the batch file there is one now! :-]

answered 25 Mar '11, 03:23

oty's gravatar image

oty
1112
accept rate: 0%