Access Millions of academic & study documents

Clianswered

Content type
User Generated
Subject
Computer Science
School
California State University Sacramento
Type
Homework
Showing Page:
1/11
1
HomeWork 5, Command Line interpreter
General rules: Create homework, compose specifications or any text by using a common
document-creation tool, such as Microsoft
®
Word.
Hints: Refer to the wwweb or lecture notes for this class to design, implement, and debug
correctly working SW solutions. Be concise, complete, and precise.
Abstract: Design, implement, explain, test, and debug a simple, but complete command-line
interpreter named cli.
Detail: Design, implement, document, test and run a simple shell, known here as a
command-line interpreter (cli). This tool is invoked via the cli command plus possible
arguments. Commands are operating system commands to be executed under the Unix (or
Linux) OS. Multiple commands are separated from one another by commas, and each may in
turn have arguments. Cli ‘knows’ a list of commands a-priori (predefined). When invoked, cli
checks, whether the first argument is an included, predefined command. If so, cli confirms
this via a brief message. If not, a contrary message is emitted, stating this is not one the
predefined commands. After the message, cli executes all commands in the order listed. After
executing the last command, cli prints the current working directory, i.e. it acts as if the pwd
command had been executed. Sample runs are shown further below.
Multiple commands of cli must be separated from one another by commas. Possible
parameters of any one command are separated from the command itself (and from possible
further parameters) by white space. White space consists of blanks, tabs, or a combination,
but at least 1 blank space. Here some sample runs with single and multiple commands;
outputs are not shown here:
./cli pwd
./cli rm f temp, mv temp ../temp1
./cli ls la
./cli rm a.out, gcc sys.c, cp a.out cli
Cli starts out identifying itself, also you the author, and the release date. Then cli prints the list
of all predefine commands. Finally, cli executes all commands input after the cli invocation. For
your own debug effort, test your solution with numerous correct and also wrong inputs,
including commas omitted, multiple commas, leading commas, illegals commands, other
symbols instead of commas etc. No need to show and hand-in your test and debug work.
The output of the cli command “cli pwd” or “./cli pwdshould be as shown below, assuming
your current working directory is ./classes_Sac_State/csc139. Here is the output of a
sample run with a single command line argument:
herbertmayer$ ./cli pwd
hgm cli 4/12/2020
Legal commands: cd exec exit gcc ls man more mv rm pwd sh touch which $path
2 strings passed to argv[]
next string is 'pwd'
new string is 'pwd '
1st cmd 'pwd' is one of predefined.
/Users/herbertmayer/herb/academia/classes_Sac_State/csc139
Here the output of another sample run, also with a single cli:
herbertmayer$ ./cli ls

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/11
2
hgm cli 4/12/2020
Legal commands: cd exec exit fork gcc ls man more mv rm pwd sh touch which
$PATH
2 strings passed to argv[]
next string is 'ls'
new string is 'ls '
1st cmd 'ls' is one of predefined.
admin cli.c sac_state_yyy
backup_1_24_2020 docs sac_state_hw
backup_3_9_2020 grades sac_state_xxx
cli l_notes
/Users/herbertmayer/herb/academia/classes_Sac_State/csc139
Interpretation of commands that cli handles can proceed through system(), executed from
inside your C/C++ program cli.
List of all commands supported by your cli:
char * cmds[ ] = {
1"cd",
"exec",
1"exit",
1"gcc",
1"ls",
1"man",
1 "more",
1"mv",
1 "rm",
1 "pwd",
1 "sh",
"touch",
1"which",
"$path"
};
What you turn in:
1. The source program of your homework solution; well commented, preferably one single
file.
2. About four progressively more complex executions of your correctly working cli program,
showing all user input and output.

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/11

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 11 pages?
Access Now
Unformatted Attachment Preview
HomeWork 5, Command Line interpreter General rules: Create homework, compose specifications or any text by using a common document-creation tool, such as Microsoft® Word. Hints: Refer to the wwweb or lecture notes for this class to design, implement, and debug correctly working SW solutions. Be concise, complete, and precise. Abstract: Design, implement, explain, test, and debug a simple, but complete command-line interpreter named cli. Detail: Design, implement, document, test and run a simple shell, known here as a command-line interpreter (cli). This tool is invoked via the cli command plus possible arguments. Commands are operating system commands to be executed under the Unix (or Linux) OS. Multiple commands are separated from one another by commas, and each may in turn have arguments. Cli ‘knows’ a list of commands a-priori (predefined). When invoked, cli checks, whether the first argument is an included, predefined command. If so, cli confirms this via a brief message. If not, a contrary message is emitted, stating this is not one the predefined commands. After the message, cli executes all commands in the order listed. After executing the last command, cli prints the current working directory, i.e. it acts as if the pwd command had been executed. Sample runs are shown further below. Multiple commands of cli must be separated from one another by commas. Possible parameters of any one command are separated from the command itself (and from possible further paramete ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4