#!/bin/bash
# example03-a
# This script is totally redundant as I could
# just use ping [ip address] and watch what happens.

# Clear does just that, it blanks your screen
clear

echo -e "Enter an IP address as: \n"

read ip_in

# Check for null variable
test -n "$ip_in"
  if [ $? -eq 1 ]; then
    echo -e "\nUsage: example_03a [IP address]\n"
    exit
  fi

# Use > /dev/null 2>&1 to redirect standard out and
# error to /dev/null because we don't need to see it
ping -c1 $ip_in > /dev/null 2>&1


# Ping will return a zero if there was a packet returned
# from the target IP
if [ $? -eq 0 ];then
	echo -e "\nPing recieved a return packet\n\n"
else
	echo -e "\nPing did not recieved a return packet\n\n"
fi

#end of script