Networking
--
Questions
--
Followers
Top Experts
Tracing route to AT1006.corpnet1.com
over a maximum of 30 hops:[xxx.xxx.xxx.xxx]
1 <1 ms <1 ms <1 ms xxx.xxx.xxx.xxx
2 <1 ms <1 ms <1 ms xxx.xxx.xxx.xxx
3 <1 ms <1 ms <1 ms xxx.xxx.xxx.xxx
4 1 ms 1 ms <1 ms xxx.xxx.xxx.xxx
5 <1 ms <1 ms <1 ms servername [xxx.xxx.xxx.xxx]
6 38 ms 41 ms 39 ms servername [xxx.xxx.xxx.xxx] e.g. this is the only line that i want to export to excel.
There are 40 servers and i can traceroute them all in a batch file but all i need is the last line exported.
Thanks and regards.
dcreedon
Alan
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
You can write a batch file with Tracert command to the servers. Execute the Batch file and pipe it to a file with csv ext. Try to open the file in Excel it will work
test.bat>test.csv
Test.bat should contain the tracert commands.
Hope it helps you
Cheers!
EG:
a1 traceip1 1.1.1.1
a2 traceip2 43.1.1.1.
a3 traceip3 2.2.24.1
a4 traceip4 2.2.45.1
a5
a6 =if(a4>0,a4,if(a3>0,a3,if(
This will display the last know IP even if they are different lengths every time.
Steve
@echo off
set logfile=c:\logfile.csv
set addresses=c:\addresses.txt
IF NOT EXIST %addresses% echo %addresses file not found. This should have each IP or hostname, one per line & goto end
echo Computer,hops,time 1,time 2,time 3, IP Address > %logfile%
for /f "tokens=1" %%y in (%addresses%) do call :process %%y
goto end
:process
echo Tracert to %1
set num= & set ms1= & set ms2= & set ms3= & set IP=
for /f "tokens=1,2,4,6,8 delims= " %%a in ('tracert -h 20 -d %1 ^| find /i "ms"') do set num=%%a & set ms1=%%b & set ms2=%%c & set ms3=%%d & set IP=%%e
echo %1,%num%,^%ms1%,^%ms2%,^%m
echo %1,%num%,^%ms1%,^%ms2%,^%m
:end






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
If you then want his to be a daily job, then my vote is to place everything that is output into a single flle (trace.log). Process the log with a language that cna identify strings, to pull out the 40 or so lines desired by parsing. Do not count on results always being on same line number, you already list twice the hops that are needed.
Thanks for all the help so far, but maybe i didn't explain myself properly before. I have a batch file thats tracerts 40 servers all at once. The ouptut gets sent to a text file and i can import that to excel and manually take the last lines out of each servers traceroute and copy into another excel sheet. Very tedious is it not. What i want to do is have a script or something that will pull the last line out of each servers traceroute (Either on the text file or excel) and put it into an excel file. This would save a lot of time. I know this can be difficult as each trace route is different on the text file, different hops, TTLs IP's etc but if this is possible any help would be greatly apprcieated.
Thanks Guys.
Have you tried the batch file I posted above. That is what it does. It takes the list of servers from the file addresses.txt, one entered per line, runs a tracert then collects that data for you into a CSV...
It does do it one after another... is that an issue?
Steve

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I ran the script and and all it did was create the excel file with no content. Can't see why it's doing that.
Thanks.
E:\scripts\>trace
Tracert to Server1.domain.internal
server1.domain.internal,10
Tracert to server2.domain.internal
server2.domain.internal,10
And the two CSV lile lines go to the screend and CSV file
In the text file addresses.txt add the IP or servername or fully qualified.
It currently sets a maximum hop of 30 which you can adjust on the tracert line and turns off name resolution with the -d option to speed it up.
Correct me if I am wrong but what I am trying to produce for you IS what you are asking for ultimately isn't it before I put any more time into it?
Steve
Networking
--
Questions
--
Followers
Top Experts
Networking is the process of connecting computing devices, peripherals and terminals together through a system that uses wiring, cabling or radio waves that enable their users to communicate, share information and interact over distances. Often associated are issues regarding operating systems, hardware and equipment, cloud and virtual networking, protocols, architecture, storage and management.