I am connecting to a telnet listener. Telnet server sends “1234” for every second. I want to read the message “1234” and close the telnet session. Here below is my code but it does not work.
#!/bin/bash
telnet 192.168.10.24 1234
read $RESPONSE
echo "Response is"$RESPONSE
echo "quit"
How can i automatically read the telnet message?
You could use internal TCP mechanism:
Or you could use nc (netcat), but please don’t use telnet!