Question: The pseudo-code below, behaves like a simple shell for interpreting simple bash scripts, that consist of a few lines. Each line is made of a

 The pseudo-code below, behaves like a simple shell for interpreting simple

The pseudo-code below, behaves like a simple shell for interpreting simple bash scripts, that consist of a few lines. Each line is made of a single shell command with or without arguments. Write a C program that uses only Unix input/outputs system calls to open the script file and to read each line until the end of the file. Each line consists of a command, except lines that start with # or that are empty, that should be ignored. Your program uses fork() and exec() to execute the commands. Synopsis: myShell Pseudo-code: Open Scriptfile while (1) /7 use perror in case of error readLine from myScriptFile if (read-error or end-of-file) //use perror in case of error quit if (line is a comment or empty) skip iteration (continue in c) extract command and arguments from line and store them in a NULL-terminated array of strings, call it myCommand duplicate current process parent process waits for its child to terminate child should exec to the new program using myCommand

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!