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

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%


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
permanent link

answered 25 Mar '11, 02:46

SYN-bit's gravatar image

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

Thanks a lot, SYNbit!

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

permanent link

answered 25 Mar '11, 03:23

oty's gravatar image

oty
1112
accept rate: 0%

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:

×37
×19
×19

question asked: 25 Mar '11, 02:12

question was seen: 4,934 times

last updated: 25 Mar '11, 03:23

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