Batch file or script to telnet to multiple hosts, log initial output then close and test next host

0

I have a large list of IP addresses from a database that I need to sanitize and determine which type of host (it'll be one of 2 device types) each IP address relates to.

Is there a way of using a batch file and/or Putty to telnet to (but not necessarily log in to) each host, check the initial message from the host, log it to a file and then disconnect and test the next one and so on?

Faldinio

Posted 2015-06-23T12:14:14.380

Reputation: 11

What operating system? What shell? Note: Welcome to Super User. Unfortunately, we are not a code-writing service. Instead of simply asking for code to perform a particular task, please show us what you've tried so far (including any code you currently have) and where you're stuck so that we can help you with your specific problem. Questions that only ask for code are too broad and are likely to be put on hold or closed. Please read How do I ask a good question?.

– DavidPostill – 2015-06-23T12:19:27.723

Apologies if you've misinterpreted the question. I'm not sure where I asked anyone for code? I want to know if it's possible before I start exploring how. I'm asking about capabilities of batch files, not requesting code. – Faldinio – 2015-06-23T13:04:32.703

I you do know how-to achieve your task for a particular (hard-coded) IP address, then yes, it's possible using modified loop: FOR /F "delims=" %%G IN (list_of_IP_addresses.txt) DO ECHO %%G – JosefZ – 2015-06-23T22:24:37.913

Answers

0

You can look in to using expect. It should suit your needs. There are a few questions/posts on here about it.

davelupt

Posted 2015-06-23T12:14:14.380

Reputation: 189