Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions