Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Abstract: Design, implement, explain, test, and debug a simple, but complete command-line interpreter named cli. Cli executes any or the Unix commands: cd, exec,
Abstract: Design, implement, explain, test, and debug a simple, but complete command-line interpreter named cli. Cli executes any or the Unix commands: cd, exec, exit, gcc, Is, man, more, mv, rm, pwd, sh, touch, which, and $path. Hints: Refer to the wwweb or lecture notes for this class to implement a correctly working SW solution. Be concise, complete, and precise. Read the man page for the system () function in C++ (or C), and consider using it to complete this homework. Detail: Design, implement, document, test, debug, 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 OS commands to be executed. Multiple commands are separated from one another by commas, and some commands may in turn require further arguments. Cli 'knows' the defined list of commands a-priori. When invoked, cli checks, whether the first argument is an included command. If so, cli confirms this via a brief message. If not, cli displays that 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 issued; then cli terminates. Sample runs below. Multiple arguments of one cli command 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 any combination, but at least 1 blank space. Here are 4 sample runs with single and multiple commands: ./cli pwd ./cli rm -f temp, mv temp../templ ./cli ls -la ./cli rm a.out, gcc sys.c, cp a.out cli Cli starts out identifying itself, also naming 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 hand-in your test and debug work. The output of the cli command "cli pwd" or "./cli pwd" should 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: looks like Unix pwd; but is your SW ditto: this is your running homework 5 another "single unix command" with args cd exec exit gcc ls man more mv rm pwd sh touch which Spath 2 strings passed to argv[] next string is 'pwd' T 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 command: herbertmayer$ ./cli ls hgm cli 4/12/2020 Legal commands: 2 strings passed to argv[] next string is 'ls'. new string is 'ls 1st cmd '1s' is one of predefined. admin cli.c docs. grades 1 notes. backup_1_24_2020 backup_3_9_2020 cli }; cd exec exit gcc 1s man more mv rm pwd sh touch which Spath "exec", "exit", "gcc", "18", "man", "more", "mv", "rm" /Users/herbertmayer/herb/academia/classes_Sac_State/cac139 A strong hint: Interpretation (i.e. real execution) of commands that c/i handles can proceed through system(), executed from inside your C/C++ program cli. List of all commands supported by your cli: char cmds [ ] { "cd", "pwd", "sh", "touch", "which", "Spath" T sac_state_yyy sac_state_hw sac_state_xxx What you turn in: 1. The source program of your homework solution; well commented, preferably one single source file. 2. Four progressively more complex executions of your correctly working cli program, showing all user inputs and corresponding output responses.
Step by Step Solution
★★★★★
3.42 Rating (152 Votes )
There are 3 Steps involved in it
Step: 1
The simple implementation of the commandline interpreter cli in C The code follows the requirements ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started