I am trying to catalog which smtp servers are used in an heterogenous pool of servers, and so far I was doing :
echo "HELO localhost" | telnet localhost 25 2>/dev/null | grep 220 #process the output of command
My problem is the server doesn't always have time to answer "220 ..." before the socket is closed.
So I'm looking of a relatively short, bash-based script that would be a bit more reliable. I couldn't find an easy way to make the command wait a few seconds before closing the TCP connection.
expect but i can't get it to work, and that requires an external file, which doesn't really fit in my auditing suite, and I can't be sure to have it available on all servers.
Any simple ideas ?
EDIT : versions (yep, old, I know):