I've about 300+ servers to check if a particular port is open.
OpenSSL is taking over 5 minutes to respond with the whole output. But I don't need the whole output. I just want to see the CONNECTED
message which pops up instantly if valid.
So, I'm terminating OpenSSL after few seconds using the below code.
Sample output:
[345534@localhost tmp]$ echo "x" | openssl s_client -connect 192.168.18.10:500
CONNECTED(00000003)
^C
For that, I'm using:
echo "x" | openssl s_client -connect 192.168.18.10:500 &
sleep 4
echo "Teriminating openssl for cleanup."
pkill -f openssl
echo "done"
Question: Is there a way to capture the OpenSSL command (running in the background) output without waiting for 5 minutes to determine if the port connection is established or not?
I've tried the below procedure, no go:
echo "x" | openssl s_client -connect 192.168.18.10:500 > /tmp/_out &
sleep 4
a=$(</tmp/_out)
echo $a
pkill -f openssl