I use the telnet command to check if MySQL port is responding.
telnet 10.10.10.24 3306
I use the ctrl character to disconnect. This is working as expected. How do I use this command in shell script?
I use the telnet command to check if MySQL port is responding.
telnet 10.10.10.24 3306
I use the ctrl character to disconnect. This is working as expected. How do I use this command in shell script?
If you're just looking to check if the port is open, try:
nc
will return 0 if the port is open and 1 if it is not. This is quite helpful for scripting as well. Omit thev
switch to keep it quiet:nc
is much better for non-interactive usage. Try something likeIf you don't have nc, you can use bash special files redirectons:
To automate telnet script, you should use expect. See the expect home page.
This is my script for any specific cases .
http://fajlinux.com.br/2014/10/10/script-monitorando-via-telnet/
I would use netcat and it's '-w' instead;
Here is how to use telnet in bash shell/expect