Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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 fork0 and exec0 to execute the commands Synopsis: myShell Pseudo-code: Open Scriptfile while (1) { readLine from myScriptFile if (read-error or end-of-file) // use perror in case of error //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 Hints: - You can reuse int readLine0, from your assignment 02, to read lines from files - You can use sscanf0 to extract the strings from a line, read by readLine), and store them in array myCommand (myCommand is an array of strings) 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 fork0 and exec0 to execute the commands Synopsis: myShell Pseudo-code: Open Scriptfile while (1) { readLine from myScriptFile if (read-error or end-of-file) // use perror in case of error //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 Hints: - You can reuse int readLine0, from your assignment 02, to read lines from files - You can use sscanf0 to extract the strings from a line, read by readLine), and store them in array myCommand (myCommand is an array of strings)

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

Know how productivity improvements impact quality and value.

Answered: 1 week ago