MIDWESTERN STATE UNIVERSITY MIDWESTERN STATE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CMPS 4103- Introduction to Operating Systems Fall semester 2019 Student...

1 answer below »
the question is in the file


MIDWESTERN STATE UNIVERSITY MIDWESTERN STATE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CMPS 4103- Introduction to Operating Systems Fall semester 2019 Student name:___________________________________________________________ Mini project #1 – POSIX Shell - due date 9/26 You are trying to get a job in a well-known operating system development company. During a job interview, a manager suggests you should be able to write a useless shell program. Let us call it MS-SHELLFISH. The shell should be able to create a new process every time the user enters a new command and immediately start reading the next command. If the command start with the letter P, it will be followed by the byte position of a character in the (this) program source code. Four children should be generated, each one of them should run a lseek. The first child will access and display the byte in the position specified in the command P, the second will display position +1, the third, position +2 and the last displays position + 3. When detecting a % sign the shell should stop running. Your mission is to write the MS-SHELLFISH program (it should be very short, less than 50 lines for sure) that creates a new process and executes the display. You will hand in the printout of your source code on the due date. You must use the CYGWIN system or any UNIX like system. Possible input: P 17 P 3 % Possible output for P 3 (Assume the source code file contains ABCDEFGHIJKLMN): DGFE Hints: notice that the first character of each command identifies the function to be performed. In order to access a file you will need to open and close it. The user never types anything wrong so you do not need to check the input for errors. It is also important to notice that you could write such a program without using fork, however you are required to do it. The difference would be that while waiting for the answer of your command, you would not be able to type other commands. An example of printing command for a single character x is printf(“text %c”,x);
Answered Same DaySep 23, 2021

Answer To: MIDWESTERN STATE UNIVERSITY MIDWESTERN STATE UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CMPS 4103-...

David answered on Sep 25 2021
150 Votes
45002/MS-SHELLFISH.sh
#!/bin/sh
# Check number of arguments
if [ $# -eq 0 ]
then
# Display hel
p
echo "Usage : $0 \n $0 myData.txt"
exit 0
fi
# Wait for user input and store in mycmd
read -p "Enter command: " mycmd
# Get the first input char like '%' or 'P'
c1=`echo $mycmd | cut -d' ' -f1`
# Continue the process, if first char is not '%'
while [ "$c1" != "%" ]
do
#...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here