How it works...

  1. Execute the script as $ bash test_ipv4.sh. Here, we are checking the connection with the 8.8.8.8  IP address. For that, we use the ping command in the if condition. If the condition is true, we will get the statement written and printed on the screen as an if block. If not, the statement in else will be printed.
  2. Execute the script as $ bash test_ip_dns.sh. Here, we are testing the connectivity using the hostname. We are also passing the ping command in the if condition and checking if the network is up or not. If the condition is true, we will get the statement written in an if block that's printed on the screen. If not, the statement in else will be printed.
  3. Execute the script as $ bash test_web.sh. Here, we are testing ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.