【发布时间】:2016-09-06 23:26:33
【问题描述】:
我正在尝试使用 tshark 命令行将wireskark pcap 文件转换为文本文件。一切看起来都不错。但我没有输出,也没有错误
public void convertPcapToTxt( ) {
try {
// setting output and input file names
String resultfile = "C:\\MY.txt";
String pcapfile = "C:\\MY.pcap";
Runtime rt = Runtime.getRuntime();
// create output
PrintStream out = new PrintStream(resultfile);
// set command line
Process proc = rt.exec("tshark.exe -V -r " + pcapfile);
//output to file
BufferedReader stdInput = new BufferedReader
(new InputStreamReader(proc.getInputStream()));
String s = null;
while ((s = stdInput.readLine()) != null) {
out.println(s);
}
//close output
out.close();
} catch (IOException io) {
io.printStackTrace();
}
}
【问题讨论】:
-
如果您尝试命令“tshark.exe -v”(小写“v”)会打印什么?如果 that 什么也没打印,可能是找不到 TShark 可执行文件。
-
当我从命令行运行此命令时,它运行良好“tshark.exe -V -r C:\MY.pcap”,因此它正在查找 tshark 并将其显示到我的屏幕上。我什至可以执行“tshark.exe -V -r C:\MY.pcap > C:\MY.txt”;并获得一个好的文本文件。我已经尝试在 java 中对其进行硬编码,但仍然没有输出或错误
-
也仅供参考。我有相同的代码工作,但使用将 pcap 转换为 xml 的命令。它运行良好。
标签: pcap