I'm writing a program that uses the "tracert" command to find traceroutes for IP addresses, which I'll then use to do some things with.
How I had planned to do this is, is by dumping the output for all IP addresses into a text file by appending with >>output.txt
and then reading it in with Python or something and turn it into something usable.
My issue with this is that tracert also shows in its output some things that are of no use to me, such as the first line that says where it's tracing to and what the maximum number of hops is, or the last line that only says: "Trace complete".
The thing is that I'm going to be tracing 3500+ IP addresses, and that number is only going to grow, so that is a whole lot of text that I'm printing in a file that is absolutely useless.
That's why my question is: Is there any way that I can modify the output of the command before saving it, in a batch file?
The command I'm running:
tracert -h 30 -w 500 XX.XXX.XXX.XX >>cmd_output.txt
The output it gives:
Tracing route to XYZ.net
[XX.XXX.XXX.XX]
over a maximum of 30 hops:
1 41 ms 18 ms 2 ms text.net [XXX.XXX.XXX.X]
2 2 ms 1 ms 1 ms text.net [XX.XXX.XXX.XXX]
3 1 ms 1 ms 1 ms text.net [XX.XXX.XXX.XXX]
4 5 ms 5 ms 5 ms text.net [XXX.XX.XX.XXX]
5 5 ms 5 ms 5 ms text.net [XXX.XX.XX.X]
6 25 ms 25 ms 25 ms XYZ.net [XX.XXX.XXX.XX]
Trace complete.