Question: Please help and thank you! Will rate 2) (13 points) The following Bourne shell script and C program can accomplish the same task: read an

 Please help and thank you! Will rate 2) (13 points) The

Please help and thank you! Will rate

2) (13 points) The following Bourne shell script and C program can accomplish the same task: read an IP address from user's input and check if the input IP address is valid or not. Shell script C program /bin/bash echo -n "Please enter the ip:" echo $iplgrep_ if [ # include int main)l int ipl-0,ip2-0,ip3-0,ip4-0; int n-0 n=scanf (" then echo "Please enter IP address following the IP address pattern" if (n!-4) { exit printf ("Please enter IP address fi following the IP address pattern"); #replace the dots in ip with spaces ip='echo $1plsed D. valid=1 C2. int valid-0; for num in $i;p do if (ip1255) valid= 2; else if (ip3c0 II ip3>255) valid= 3; else if ( if [ then D2. ) valid = 4; echo "INVALID: Please enter a number between 0-255 in field $n (index starts from 1 from left)" if valid-0 exit printf ("INVALID: Please enter a number between 0-255 in field %d (index starts from 1 from left) ", valid); fi n-expr $n + 1 Jelsef printf ("The ip you entered is done if [ $valid -eq 1then fi valid "); echo "The ip you entered is valid" return 0; 2) (13 points) The following Bourne shell script and C program can accomplish the same task: read an IP address from user's input and check if the input IP address is valid or not. Shell script C program /bin/bash echo -n "Please enter the ip:" echo $iplgrep_ if [ # include int main)l int ipl-0,ip2-0,ip3-0,ip4-0; int n-0 n=scanf (" then echo "Please enter IP address following the IP address pattern" if (n!-4) { exit printf ("Please enter IP address fi following the IP address pattern"); #replace the dots in ip with spaces ip='echo $1plsed D. valid=1 C2. int valid-0; for num in $i;p do if (ip1255) valid= 2; else if (ip3c0 II ip3>255) valid= 3; else if ( if [ then D2. ) valid = 4; echo "INVALID: Please enter a number between 0-255 in field $n (index starts from 1 from left)" if valid-0 exit printf ("INVALID: Please enter a number between 0-255 in field %d (index starts from 1 from left) ", valid); fi n-expr $n + 1 Jelsef printf ("The ip you entered is done if [ $valid -eq 1then fi valid "); echo "The ip you entered is valid" return 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!