Question : Can you send batch file commands to a TelNet session?

I would like a batch file that logs into a simple telnet session, logs in, performs a couple commands, then terminates. How can this be done? My humble attempt started the TelNet session, but did not enter the rest of the commands until after I manually terminated the session.

Would appreciate the help.

ie.
====================
telnet ip.add.re.ss
[username]
[password]
[carriage return]
[command]
[command]
exit

Answer : Can you send batch file commands to a TelNet session?

Not any easy way which I knew of. I can think only of one approach while using netcat: netcat in Listen mode, as a pipe proxy. It's tricky, but it might work.

First, the netcat will start in Listen mode, as a background process. It listens to local port 60023, and piping whatever comes over that port to the target. Because of -L (instead of -l), netcat remains in listen mode after a connection (on 60023) is closed - why need this will follow.
Then era is pushed to the listening netcat, which pushes it again to the target. The connection to 60023 is closed, but because of -L, the "server" process does not stop.
This gives us the chance to wait for 4 seconds (ping -n 5), and paste the rest of data to the target via the listening netcat.
The listening netcat does not terminate by itself, so we have to kill it after work is done.

1:
2:
3:
4:
5:
start "NetCat Waiting" /min cmd /c "nc -L -p 60023 -t | nc -t x.x.x.x 23"
echo era | nc 127.0.0.1 60023
ping -n 5 127.0.0.1 > nul
nc 127.0.0.1 60023 < login.txt
taskkill /IM nc.exe
Random Solutions  
 
programming4us programming4us