If you don't want to rely on external commands, and instead decide you want to leverage bash native TCP sockets (and also specify a custom port number and connection timeout period): host="port=80 Nc -G$timeout -z "$host" "$port" &> /dev/null host="ping -c1 "$host" &> /dev/nullĪlternatively, you can use nc to specify a custom port number and connection timeout period: # Note: w/ the macOS BSD version of `nc` you use the `-G` flag rather than the `-w` flag to specify the connection timeout. Replace with or any host you desire in the following examples. ![]() There a few ways you can verify internet connectivity the simplest of which is to just ping an external host (one that you expect to be up), then check the status code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |