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 |
2 Answers:
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:
Where convert.bat should look something like:
answered 25 Mar '11, 02:46 SYN-bit ♦♦ |
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 |