Ping returns different exit codes depending on the type of error.
ping 256.256.256.256 ; echo $?
# 68
ping -c 1 127.0.0.1 ; echo $?
# 0
ping -c 1 192.168.1.5 ; echo $?
# 2
0 means host reachable
2 means unreachable
More Related Contents:
- How to test an Internet connection with bash?
- what exactly env command do? [duplicate]
- Are double square brackets [[ ]] preferable over single square brackets [ ] in Bash?
- Android: How to check if the server is available?
- How to list variables declared in script in bash?
- Bash variable substitution vs dirname and basename
- Is the behavior behind the Shellshock vulnerability in Bash documented or at all intentional?
- Why bash alias doesn’t work in scripts? [duplicate]
- pipe stdout and stderr to two different processes in shell script?
- Switch case with fallthrough?
- How do I get both STDOUT and STDERR to go to the terminal and a log file?
- Is bash a programming language?
- Extract parameters before last parameter in “$@”
- -bash: __git_ps1: command not found
- Retry a Bash command with timeout
- Read n lines at a time using Bash
- Use GNU find to show only the leaf directories
- Get the name of the caller script in bash script
- Reading lines in a file and avoiding lines with # with Bash
- How does testing if a string is ‘greater’ than another work in Bash?
- How to append a string at end of a specific line in a file in bash [duplicate]
- Missing Carriage Return in Docker for Mac Containers
- Reading lines from two files in one while loop
- What is the shortest way to get n-th column of an output?
- Getting a ‘source: not found’ error when using source in a bash script
- docker entrypoint running bash script gets “permission denied”
- What does `kill -0 $pid` in a shell script do?
- How do I kill a backgrounded/detached ssh session?
- Creating tar file and naming by current date
- Can bash script be written inside a AWS Lambda function