Wireshark-users: Re: [Wireshark-users] Trouble converting .pcap file to XML (pdms) via command li
Sorry I missed your reply.
All I'm really doing is creating a Windows process and starting Tshark
with the -r and -T arguments. Once running, I populate a string with
the standard output using the Process.StandardOutput.ReadToEnd()
method. From there, you can do whatever you want with it.
Namely...persist that string to a file.
C# snippet:
private string ConvertPcapFileToXML(string TsharkPath,
string SourcePcapFilePath)
{
string Arguments;
string OutputText = "";
Process p;
ProcessStartInfo StartInfo;
try
{
Arguments = String.Format("{0} {1} {2} {3}",
"-r",
SourcePcapFile,
"-T",
"pdml";
StartInfo = new ProcessStartInfo();
StartInfo.CreateNoWindow = true;
StartInfo.FileName = TsharkPath;
StartInfo.Arguments = Arguments;
StartInfo.UseShellExecute = false;
StartInfo.RedirectStandardOutput = true;
StartInfo.RedirectStandardError = false;
p = new Process();
p.StartInfo = StartInfo;
p.Start();
OutputText = p.StandardOutput.ReadToEnd();
}
catch (Exception ex)
{
_AppLogger.LogException(ex);
}
return OutputText;
}
>From: Stephen Fisher <steve@xxxxxxxxxxxxxxxxxx>
>Date: Sat, 13 Nov 2010 15:28:04 -0700
>
> On Sat, Nov 13, 2010 at 03:47:57PM -0500, Sean Sparacio wrote:
>
>> I actually came up with a programmatic workaround, which I should have
>> done in the first place, as this will need to be an automated process.
>
>Care to share it with the list for others?
>
>> I very much appreciate the reply though, Stephen.
>
>You're welcome.