echo > /dev/tcp/${HOSTNAME}/${PORT} You can check the communication with the TCP port of the target host. If communication is OK, nothing will be returned, so it may be better to define a response when it is OK, such as && echo "OK" as shown below.
sh-4.2$ echo > /dev/tcp/$DATABASE_SERVICE_NAME/3306 && echo "OK"
OK
sh-4.2$ echo > /dev/tcp/$DATABASE_SERVICE_NAME/3305 && echo "FAIL"
sh: connect: No route to host
sh: /dev/tcp/quotesdb/3305: No route to host
For reference, if you have the following link, you don't need this article ... (laughs) https://qiita.com/oba23/items/e3038d8f388aa435b7d8
Recommended Posts