exit from telnet in bash script using nc command in Rhel 7

Latest response

exit from telnet in bash script using nc command in Rhel 7

Responses

Hi Ahmed,

Let me try to guess what you need:

You are trying to test some port via netcat instead of telnet?

Here is a simple solution: which assumes you want to open TCP port 80 on remote server myserv.domain.dom:

echo | nc -tv myserv.domain.dom 80 >/dev/null 2>&1

Then, you can do simple verification like:

if [ $? -ne 0 ]
then
   echo "INFO: myserv.domain.dom@80 is not reachable"
fi

Regards,

Dusan Baljevic (amateur radio Vk2COT)