1.

Solve : Batch file to run Telnet command that looks up a list?

Answer»

hi there. . I need some help automating a script.

This will be for multiple devices located in a hospital that i will need to terminal to. Each device in a room has a static IP.

I need a batch file called tel.bat or something that would do this

c:\Tel 454

the 454 being any room number i need to telnet to at taht time

i want the batch file to look up that room number on a list and match it to an ip then telnet to it. im assuming comma DELIMITED format exported from excel. so it would be like

454,172.1.1.1
455,173.1.1.1

etc on the list.

how do i do this? im TIRED of LOOKING up hundreds of these ip addresses of these each day..

thank you in advance.
Quote

i want the batch file to look up that room number on a list and match it to an ip then telnet to it. im assuming comma delimited format exported from excel. so it would be like

454,172.1.1.1
455,173.1.1.1

If Excel quotes each of the fields in the comma SEPARATED file, the code can modified to take that into account.

The snippet below uses the above file labeled room.csv

Code: [Select]echo off
set /p rm=Enter Room Number:
for /f "tokens=1-2 delims=," %%i in (room.csv) do (
if %rm%==%%i telnet %%j
)

If needed the code can be modified to LOOP should the user enter an incorrect room number.

Good luck.


Discussion

No Comment Found