-
Jan 5th, 2010, 07:31 AM
#1
Thread Starter
Addicted Member
Parsing of text
Hi all,
i am trying to read the route table in the application. I want to seperate the result into multiple files.
Code:
static void Main(string[] args)
{
System.Diagnostics.Process.Start("cmd.exe", @"/c route print > d:\test.txt");
}
On running this i get a test.txt file which has following data
Code:
===========================================================================
Interface List
11...00 21 97 60 87 b2 ......Marvell Yukon 88E8056 PCI-E Gigabit Ethernet Controller
1...........................Software Loopback Interface 1
12...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
13...00 00 00 00 00 00 00 e0 Teredo Tunneling Pseudo-Interface
===========================================================================
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.10.254 192.168.10.71 276
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
192.168.10.0 255.255.255.0 On-link 192.168.10.71 276
192.168.10.71 255.255.255.255 On-link 192.168.10.71 276
192.168.10.255 255.255.255.255 On-link 192.168.10.71 276
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 192.168.10.71 276
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 192.168.10.71 276
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
0.0.0.0 0.0.0.0 192.168.10.254 Default
===========================================================================
IPv6 Route Table
===========================================================================
Active Routes:
If Metric Network Destination Gateway
13 58 ::/0 On-link
1 306 ::1/128 On-link
13 58 2001::/32 On-link
13 306 2001:0:4137:9e50:4a:3687:3f57:f5b8/128
On-link
11 276 fe80::/64 On-link
13 306 fe80::/64 On-link
13 306 fe80::4a:3687:3f57:f5b8/128
On-link
11 276 fe80::570:3b43:1288:342/128
On-link
1 306 ff00::/8 On-link
13 306 ff00::/8 On-link
11 276 ff00::/8 On-link
===========================================================================
Persistent Routes:
None
My first text file needs to have active routes details and the second one needs to have persistent routes details. the text will be varying from pc to pc. What can be a good method to split the data
If you found my reply helpful, please rate me
-
Jan 5th, 2010, 04:13 PM
#2
Frenzied Member
Re: Parsing of text
The problem is that as you say the text will vary from PC to PC and as such simply using LINQ will not suffice. My advice is to try find a pattern for each point of data you need, this could be a number of spaces or knowing your information comes after a certain piece of information and then grab it using regular expressions.
As they are a bit of an art form I couldn't just come up with one, they tend to take trial and error unless you are fairly proficient at them (Im not) but that would be the best method!
-
Jan 6th, 2010, 12:33 AM
#3
Thread Starter
Addicted Member
Re: Parsing of text
Lets say i want to split the data in active route and presistent route in the above text file. What can be a way
If you found my reply helpful, please rate me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|