Project #4 Solution

$29.99 $18.99

Assignment Overview For this assignment, you are to design and implement a C/C++ program that will serve as an interpreter for shell scripts, as defined below. You will design and implement additional functionality in subsequent projects. Assignment Deliverables The deliverables for this assignment are the following files: proj04.makefile – the makefile which produces proj04 proj04.student.c…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product

Assignment Overview

For this assignment, you are to design and implement a C/C++ program that will serve as an interpreter for shell scripts, as defined below. You will design and implement additional functionality in subsequent projects.

Assignment Deliverables

The deliverables for this assignment are the following files:

proj04.makefile – the makefile which produces proj04 proj04.student.c – the source code file for your solution

Be sure to use the specified file names and to submit your files for grading via the CSE Handin system before the project deadline.

Assignment Specifications

  1. The purpose of the program is to interpret the contents of a text file as a series of directives (defined below). The user will supply zero or more command line arguments to control execution of the program.

  1. The program will process the command line arguments from left to right.

  1. If an argument begins with the character ‘-‘, it will be processed as an option which controls the behavior of the program. Valid options are “-v” and “-s” (defined below).

  1. If an argument does not begin with the character ‘-‘, it will be processed as a file name. The user will supply zero or more file names, where each input file contains zero or more lines of text.

  1. For each input file, the program will repeatedly read a line of text and process it. An input line is defined as a

sequence of zero or more tokens (character strings), separated by one or more delimiters (blanks and tabs), ending with a newline character. There will be no more than 128 characters in a line.

If the first token is the name of a built-in directive (listed below), then the program will take the appropriate action. Otherwise, the program will assume that it is an error.

3. The program will recognize the following built-in directives:

  1. The “exit” directive will terminate processing of the current input file. End-of-file on the current input file will be processed as an implicit “exit” directive.

  1. The “date” directive will display the current date and time in a human-readable format.

  1. The “env” directive will display the user’s environment variables in a format similar to “setenv” in the C shell.

  1. The “path” directive will display the current search path in a readable format.

  1. The “cwd” directive will display the absolute pathname of the current working directory.

  1. The valid command line options are “-v” (verbose) and “-s” (silent). An option applies to file names which appear after the option on the command line.

  1. When the “-v” option is in effect (which is the default), the program will display the sequence number of the current line of text from the input file (starting at 1 for each input file) and the current line of text. The sequence number will be enclosed in the characters ‘<‘ and ‘>’. For example:

<1> cwd

  1. When the “-s” option is in effect, the program will not display the sequence number or the current line of text.

5. The program will include appropriate logic to handle exceptional cases and errors.

Assignment Notes

  1. As stated above, your source code file will be named “proj04.student.c”; that source code file may contain C or C++ statements.

  1. You must use “g++” to translate your source code file in the CSE Linux environment.

  1. As stated above, the command-line arguments will be processed from left to right. For example, consider the following command line:

proj04 testA -s testB testC –v testD testE –s testF

The “-v” option will be in effect for files “testA”, “testD” and “testE”; the “-s” option will be in effect for files “testB”, “testC” and “testF”.

  1. Information about system calls and library functions which might be useful for this project may be viewed using the “man” utility. For example:

man 2 time

man 3 ctime

man 3 getcwd

man 3 string

  1. As noted above, you will extend your program in subsequent projects, so you would be wise to properly structure and comment your source code.