Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following shell script is used to check if the input IP address is invalid o

ID: 3936087 • Letter: T

Question

The following shell script is used to check if the input IP address is invalid or not.
Need help with this question. Thank you. rs=1 while t Srs -gt o 1: do clear echo -n "Please input the ip: read ip #use egrep to check if the input IP address follows the IP address pattern if $isIP then a="echo bs'echo c="echo d="echo $ip $ip $ip $ip | awk l awk | awk l awk -F. -F- -F . -F· '{print '{print . {print "(print $1}'. $2 $3)' $4}'. isvalid=0; for n in $a $b $c $d; do if [ li then -o echo "ERROR: The number of the IP should not be greater than 255 and less than 0" break; fi done if [ fi ); then echo"--This is a valid IP" " else echo "ERROR: The IP format you input is wrong, the format should be like 192.168.100.1" fi echo echo -n "press 0 to exit and other numbers to continue..." read done

Explanation / Answer

Writing in order, the input was provided:

isip = 'egrep -q '^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$'

if [ ($n>255) -o ($n<0) ]; then

isValid = 1

if [ $isValid -ne 1 ]; then

read -n rs