C program generation, write C language work, Systems programming write, do C programming

Source: Internet
Author: User
Tags posix stdin

CITS2002 Systems Programming-project 2 2017
See Also:2 Project 2 clarifications
A shell is a command-interpreter used widely on unix-based systems. Most shells receive character-based input, typically read from a keyboard or a textfile, parse
Their input into a tokens sequence forming the syntax recognised by the shell (command names, command arguments, and contro L-flow delimiters), and then attempt to
Execute the token sequence. The shell used by more csse students under MacOS and Linux is named Bash (the Bourne Again shell); A former Csse graduate is the author of
A very popular book describing the Bash shell.
The goal of this project are to implement a program named Myshell supporting a small subset of the features of a standard U nix-based Shell. Successful completion of the
Project would develop your understanding of some advanced features of the C99 programming language, and your understanding Of the role of a number of system-calls
Responsible for process invocation and monitoring, and input and output management using file and pipe descriptors.
Note-this is a systems-specific project. You'll find this project significantly easier to complete on MacOS or Linux. You'll likely have great difficulty
Completing it on Windows, and it's recommended that's you don ' t try. As for the 1st project, your submission'll be is tested and marked on Csse MacOS Laboratory
Machines.
________________________________________
Suggested steps
A number of C99 source code files is provided as a starting skeleton for the project. The most challenging-to-write part of the project, the command parser, have been
Written for you, and should is used without modification (and need not being understood). The parser returns a pointer to a binary tree of shell commands which your code
would traverse and execute.
In summary, the function parse_shellcmd (file *FP) accepts a file pointer as it only input, and attempts to read and parse its input. If successful, function
Parse_shellcmd () Returns a pointer to a user-defined datatype named Shellcmd, a self-referential structure holding all INF Ormation necessary to execute the requested
Command-sequence. Your role is-to-execute the commands in the structure by (implementing and) calling Your own function named EXECUTE_SHELLC MD ().
The project is only requires implementation of a small subset of a traditional Unix shell. However, that subset'll be is quite faithful to standard shells. For this
Reason, this project description does not specify all details in great detail. If unsure about the role and action of Shell features listed in these steps, you should
Experiment with the same feature in your standard shell, bash (or obviously ask on help2002).
The approach taken to develop the sample solution have been broken into 9 independent steps, presented below. There ' s no requirement for the follow these steps, but
They is described here's provide an obvious pathway to a solution, and to explain the project ' s required features.
Step 0. Develop a Makefile
Develop a Makefile, employing variable definitions and automatic variables, to compile and link the project's files.
Step 1. Execute Simple external commands
1.execute commands without arguments, such as/bin/ls
2.execute commands with arguments, such as/usr/bin/cal-y
Helpful C99 and POSIX functions:fork (), EXECV (), exit (), wait ().
The Functions:system (), Popen (), EXECLP (), or EXECVP () anywhere in your project.
Step 2. Search Path
The global variable PATH points to a character string which is interpreted as a colon separated list of directory names.
If the user enters a command name which does not contain a '/' character and then the members of the search path list is con Sidered as directories from which to attempt
To execute the required command. Once the required command is found and executed, the search terminates.
Helpful C99 and POSIX functions:strchr ().
Step 3. Execute internal Commands
Internal commands is performed by Myshell, itself, rather than by external commands. Myshell does not create a new process, with fork (), before running an internal
Command. Three internal commands is to be supported:
1.exit-terminate Myshell by calling the function exit (). When a additional argument is provided, it should be interpreted as the numeric exit-status. When
Requested without any arguments, the exit-status of the recently executed command should is used.
2.cd-change from the current working (default) directory to the directory specified as the first argument to the CD comm and. If the command CD is given without
Arguments, then the variable HOME should is used as the new directory.
As with the role of PATH for command execution, the variable cdpath points to a character string which are interpreted as a Colon separated list of directory names. If
The user enters a directory-name which does not contain a '/' character and then the members of Cdpath is considered as dire Ctories to locate the required directory.
3.time-the ' following ' command ' s execution time should be reported in milliseconds (e.g. 84msec) to Myshell ' s stderr str Eam.
Helpful C99 and POSIX functions:exit (), ChDir (), Gettimeofday ().
Step 4. Sequential execution
There is three forms of sequential execution, and thus three subparts to this step. The three forms differ in the action they take when a command fails. By
Convention, a command which fails would return a Non-zero exit status.
1.A sequence of commands separated by the ";" tokens requires Myshell to execute each command sequentially, waiting until E Ach command has finished before
Beginning the next. In this form, Myshell should continue to the next command regardless of the result of earlier commands. The sequence LS; Date Monday; Ps
Would execute LS, then on its completion execute date Monday (which would fail), then execute PS (even though the previous Command failed). The exit value of sequential
Execution is the exit status of the "the" and the "sequence to the right" token.
2.If the commands is separated by the token ' && then Myshell should continue with further commands only If the C Ommand sequence to the left of the token
Returns an exit value indicating success. For the command sequence a && B, Myshell should wait for command A to terminate, test its return value and execute b if and
Only if a S return value indicates success. The exit value of a "&&" command sequence is the exit status of the last command executed.
3.If the token "| |" is used to separate commands then Myshell should continue to the next command only If the first Comman D sequence returns an exit value
Indicating failure. This is the converse of Part 2. For the command sequence a | | B, Myshell should wait for command A to terminate, test its return value and execute
b if and only if a ' s return value indicates failure. The exit value of a "| |" command sequence is the exit status of the last command executed.
Step 5. Subshell execution
The sequence (commands) should cause commands to being executed in a subshell. A subshell is created by forking a copy of Myshell to execute the commands. The exit
Value for a subshell is the exit value of the command sequence inside the parentheses.
Step 6. stdin and stdout file redirection
Commands redirect their standard input and standard output from and to files, respectively, before the command is exec Uted.
1.The sequence Command < infile requests, the command use infile as their standard input.
2.The sequence Command > outfile requests the command use outfile as it standard output. If The file outfile does not exist then it is created. If it
Does exist it is truncated to zero and then rewritten.
3.The sequence Command >> outfile requests that the command appends their standard output to the file outfile. If outfile does not exist it is created.
Note:in all of the above cases command could be a subshell. It is valid to has both input and output redirection for the same command. Thus the sequence (sort;
PS) < Junk1 >> Junk2 would take input from the file Junk1 and append output to the file JUNK2.
Helpful C99 and POSIX Functions:open (), Close (), dup2 ().
Step 7. Pipelines
The Sequence Command1 | Command2 requests that the stdout of Command1 is presented as stdin to Command2. By default, the stderr output of Command1 was not
Redirected and appears at their default location (typically the terminal). With reference to this example, the Myshell parser won't permit the stdout of Command1 to
Be redirected to a file (with >), nor the stdin of Command2 to is received from a file (with <). Note that the sequence Command1 | Command2 | Command3 requests that
A pipeline of different pipes be established.
Helpful C99 and POSIX functions:pipe (), dup2 ().
Step 8. Shell scripts
Once an executable file name have been found (possibly using the search path) the standard function execv () can be called T o try to execute it. If execv () fails, you
Should assume the file is a shell script (a text file) containing more Myshell commands. In the should execute another copy of Myshell to read its input
From the shell script. No specific filename extension is required.
Helpful C99 and POSIX functions:access (), fopen (), fclose ().
Step 9. Background execution
The token "&" causes the preceding command to being executed without myshell waiting for it to finish (asynchronously). Thus the sequence LS; PS & Date should start
The command sequence LS, once this have completed start PS and immediately proceed to the command date. The exit value of background execution is success unless the
Fork call fails, in which case the exit value should indicate failure.
Commands placed into the background is a long time to execute and, thus, we wish to know when they has completed. The parent is informed of the termination of
Child processes using asynchronous signal-passing. When so informed, Myshell should the which background process has terminated.
Similarly, when Myshell exits, it should first terminate all of its still-running background processes, and wait for them To finish.
Helpful C99 and POSIX functions:signal () and kill ().
________________________________________
Starting files
The amount of code to being written for this project are similar to that of the 1st project, although less needs to be Designe D "from scratch" because you ' re extending an
(incomplete) Code skeleton.
An executable sample solution would be available soon.
Start your project by downloading, reading, and understanding the files in the archive myshell.zip.
Myshell.h-provides the definition of Myshell ' s user-defined datatypes and the declaration of global variables.
? Myshell.c-provides the main () function, and calls the Parse_shellcmd () function.
? globals.c-defines global variables, and the helpful print_shellcmd0 () function.
? execute.c-where you define your Execute_shellcmd () function.
Parser.c-defines the Parse_shellcmd () and Free_shellcmd () functions, which should be used without modification (and nee D not being understood).
Modify any file or add any additional files to your project.
________________________________________
Program Requirements
1.Your project, and its executable program, must is named Myshell.
2.Your project must be developed using multiple C99 source files and must employ a Makefile, employing variable definition s and automatic variables, to compile
and link the project s files.
3.If any error was detected during its execution, your project must use fprintf (stderr, ....) or perror () (as appropriate) To print an error message.
4.Your project must employ sound programming practices, including the use of meaningful comments, well chosen identifier n Ames, appropriate choice of basic
Data-structures and Data-types, and appropriate choice of control-flow constructs.
________________________________________
Assessment
This are worth 15% of your final mark for CITS2002. It'll be marked out of 40. The project is completed individually or in teams of. You are strongly
Encouraged to work with someone else-this would enable you to discuss your initial design, and to assist each of the other to de Velop and debug your joint solution.
During the marking, attention'll obviously is given to the correctness of your solution. However, a correct and efficient solution should not being considered as the
Perfect, nor necessarily desirable, form of solution. Preference'll is given to well presented, well documented solutions that use the appropriate features of the
Language to complete the tasks in a easy to understand and easy to follow manner. That is, does not expect to receive full marks for your project simply because it works
correctly. Remember, a computer program should isn't only convey a message to the computer, but also to other human programmers.
Up to half of the possible marks would come from the correctness of your solution. The remaining marks would come from your programming style, including your use of
Meaningful comments, well chosen identifier names, appropriate choice of basic data-structures and data-types, and APPROPR Iate choice of Control-flow constructs.
Your project would be marked on the computers in Csse Lab 2.03, using the MacOS environment. No allowance would be made for a program this "works at home" and not on
Csse Lab 2.03 computers, so is sure that your code compiles and executes correctly on these machines before you submit it.
________________________________________
Submission Requirements
1.The deadline for the project is 12noon Friday 3rd November (end of week 13).
2.Your submission would be compiled, run, and examined using the MacOS platform on computers in Csse Lab 2.03. Your submission must work as expected on this
Platform. While develop your project on other computers, excuses such as "it worked at home, just not in the lab!" would not Be accepted.
3.Your Submission ' s C99 source files should each begin with the lines:
4.
5./*
6. CITS2002 Project 2 2017
7. Name (s): Student-name1 (, student-name2)
8. Student number (s): Student-number-1 (, Student-number-2)
9. Date:date-of-submission
10. */
11.You must submit your project electronically using Cssubmit. No other method of submission is allowed. You should submit all C Source-code (*.C) and header
(*.h) files and a Makefile that's wish to be assessed. You don't need to the submit any additional testing scripts or files, used while developing your project.
If working as a team, only one team member should make the team ' s submission. The Cssubmit facility would give you a receipt of your submission. You should print and
Retain this receipt in case of any dispute. Note also the Cssubmit facility does not archive submissions and would simply overwrite any previous submission with
Your latest submission.
12.You is expected to has read and understood the University ' s guidelines on academic conduct. In accordance with this policy, discuss
Students the principles required to understand this project, and the work you submit must be the result of your OW N efforts. All projects'll be compared
Using software that detects significant similarities between source code files. Students suspected of plagiarism'll be interviewed and would be required to
Demonstrate their full understanding of their project submission.
Http://www.daixie0.com/contents/13/1236.html

The core staff of the team mainly include Silicon Valley engineers, bat front-line engineers, domestic TOP5 master, PhD students, proficient in German English! Our main business scope is to do programming big homework, curriculum design and so on.

Our Direction field: Window Programming numerical algorithm AI Artificial Intelligence financial statistical Metrology analysis Big Data network programming Web programming Communication Programming game Programming Multimedia Linux plug-in programming API image processing embedded/Microcontroller database programming console process and thread Network security assembly language Hardware programming software Design Engineering Standard Rules. The generation of programming languages or tools including, but not limited to, the following ranges:

C/c++/c# Write

Java Write generation

It generation

Python writes

Tutoring Programming Jobs

The MATLAB Generation writes

Haskell writes

Processing Write

Linux Environment Setup

Rust Generation Write

Data Structure assginment Data structure generation

MIPS Generation Writing

Machine Learning Job Writing

Oracle/sql/postgresql/pig database Generation/Generation/Coaching

Web development, Web development, Web site jobs

Asp. NET Web site development

Finance insurace Statistics Statistics, regression, iteration

Prolog write

Computer Computational Method Generation

C program generation, write C language work, Systems programming write

Because of professional, so trustworthy. If necessary, please add qq:99515681 or e-mail:[email protected] : Codinghelp

C program generation, write C language work, Systems programming write, do C programming

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.