首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
讲解Basic Command Shell、C++语言辅导、C++程序调试、辅导square brackets 辅导留学生 Statistics
Assignment 2
Writing a Basic Command Shell
This project must be done in a group of two
Coding Requirements
Develop a command shell called rshell in C++ which is capable of performing the following
steps:
1. Print a command prompt (e.g. `$`)
2. Read in a line of command(s) (and connector(s)) from standard input
3. Execute the appropriate commands using fork, execvp, and waitpid
Commands will have the following format (note that the square brackets represent optional
portions of an input):
$ executable [argumentList] [connector] [executable] ...
Where there can be any number of commands (which are composed of executables and
argument lists) separated by either ||, && or ; which are the only valid connectors. The
executable can be any executable program located at one of the PATH environment variable
locations and the [argumentList] is a list of zero or more arguments separated by spaces.
Note: The [argumentList] can also be surrounded by quotation marks which you must account
for. For instance, the command echo “hello && goodbye” would have the “hello &&
goodbye” be the [argumentList] even though without the quotes the && would separate the
goodbye into its own executable.
You will use the execvp command to run the executable from one of the PATH locations. The
connector is an optional way you can run multiple commands at once. If a command is followed
by ;, then the next command is always executed; if a command is followed by &&, then the
next command is executed only if the first one succeeds; if a command is followed by ||, then
the next command is executed only if the first one fails.
Note: you may have questions about how a specific command or set of commands should
execute. If you are unsure how a certain combination of true/false executions and connectors
will function you should test this on hammer.Note: Most bash commands are actually executables located in PATH directories such as
/bin, /usr/bin/ (e.g. ls), but some commands are built-in to bash (e.g. cd). So while the
ls command should "just work" in your shell when using execvp, the cd command won't and
isn't required to for the assignment. Only commands that can be executed through a PATH
directory need to be accounted for in this assignment.
The connectors do not impose any precedence and the command line should be execute from
left to right. For example:
$ ls -a
$ echo hello
$ mkdir test
is equivalent to:
$ ls -a; echo hello; mkdir test
Note: you can assume that there will always be a space after the semi-colon (;) connector
and before and after the and (&&) and or (||) connectors.
You are required to use the composite pattern when representing the commands and
operators in your program. There should be no limit to the number of commands that can be
chained together using the connections, and your program must be able to handle any
combination of operators. For example, you should be able to handle the command:
$ ls -a; echo hello && mkdir test || echo world; git status
When executing a line of commands, you will need to account for the following requirements:
1. Execute the commands using the syscalls fork, execvp, and waitpid. Previous cs100
students created two video tutorials a fun cartoon tutorial as well as a more serious
explanation, and should refer to the man pages for detailed instructions.
2. Every time you run a syscall, you must check for an error condition and if an error occurs
then call perror. For examples on when, how, and why to use perror, see this video
tutorial or the official man page.
3. You must have a special built-in command of exit which exits your program. This
command should also adhere to the connector rules when deciding when/if it should be
executed.
4. Anything that appears after a # character in the line should be considered a comment.
For example, in the command ls -lR /, you would execute the program /bin/ls
(performed using execvp) passing into it the parameters -lR and /. But in the commandls # -lR /, you would execute /bin/ls, but you would not pass any parameters
because they appear in the comment section. You should also note that the # may or
may not be followed by a space before the comment begins
Note: Building the parser for this program is one of the most important parts. There are many
ways accidentally introduced bugs into your program and you will be adding more parsing
features in future assignments. You can create your own parsing function from scratch or use
the strtok function from the C standard libraries or the Tokenizer class provided in the boost
library.
Important Notes for Hammer
The hammer server is provided by the CS department as a standard environment which you
can use to test your code in the same environment that it will be graded in. However, because
everyone in the class is using this server to run their assignments there are some imposed
limitations around the number of processes you can run to keep the server running well. Please
take very special note of the following advisories when using the hammer server.
● No Graphics: because hammer is a true server you will not have access to any
applications which require graphics such as web browsers or graphical editors.
● One SSH Session: because the hammer server limits the number of processes you can
run at any given time if you are connecting to hammer through multiple sessions (ssh,
putty, etc.) this will limit the number of other processes you can run. For this reason you
should only use a single connection, if you need multiple windows there are other
methods (screen, sleeping processes, etc.) to navigate the system better without
multiple connections. You should also properly close your SSH connection so that they
do not continue to live on the server side. This is typically done by executing exit on
the command line you are connected to.
● Be Careful when Forking: each time you execute a fork() function you are creating a
new process which will execute until it terminates (via exit() or some other program
termination). One very common issue is for students to create fork() program that do not
properly exit and instead build up over time until they use up all the processes you are
alloted on hammer, at which point you will not be able to ssh or perform other normal
programs (because you have no available processes).
In order to check for this issue you can use the command line command ps -uxwwf and look
for a buildup of processes (typically named after the program you are executing like rshell). You
can then destroy any accidental processes using the command kill -KILL
where
you replace
with the PID number that displays when you run ps -uxwwf .If your session gets really stuck, you can use killall -KILL -u
to kill all the
processes you own (you must use your own username) which will disconnect you and kill all the
processes you have running. Note that by killing all the processes you have running you will
lose any changes from files you were editing on the server.
Project Structure
You must have a directory called src/ which contains all the source (.cc/.cpp) files for the
project. For header files you may either have a folder header/ which contains your header files
or you may keep them in the src/ directory. You must have a unit_tests/ directory which
should contain all the unit tests you've written using the Google Unit Test framework (the main
for the unit tests can be located either in unit_tests/ or src/). You must also have an
integration_tests/ directory which should contain all the integration tests you’ve written
using bash. We recommend using IO redirection for your bash integration tests, and automated
validation is not necessary.
Your root directory must have a CMakeLists.txt with two targets. The first target is named
rshell and should build the main executable and the second should be test which runs the
unit tests that you have created using the Google Unit Test framework.
Note: The file/directory names above are a standard convention. You must use the exact
same names in your project, including capitalization. We utilize these names when performing
steps of our automated grading process, so any deviation may result in missing points.
The google test code for your unit tests can have any name as long as the files reside in the
unit_tests/ directory and an executable is generated named test in the root directory. The
integration test shell scripts that you develop and place into the integration_tests/
directory must have the following names:
single_command_tests.sh tests primarily for command executions
multiple_commands_tests.s
h
tests primarily for command and connectors interaction
commented_command_tests.s
h
tests primarily for comments being respected
exit_command_tests.sh tests primarily for proper exit functionality
Your project should not contain any files not necessary for the project. This includes things like
CMake temporary build files used for building the project on your machine such as
CMakeCache.txt and the CMakeFiles/ directory as well as executables. We have provideda .gitignore in the template repository which will stop may of these files from showing as
untracked when you run git status, and you should extend this file with additional temporary and
machine specific files.
Submission Instructions
You will also need to add an annotated hw2 tag to the commit that you want to be graded.
Annotated tags are described in lab 2 and in the git documentation. git push will not
automatically push tags to your repository. Use git push origin hw2 to update your
repository to include the hw2 tag. If you need to update your tag, you can remove the old tag
using git push --delete origin hw2 and push an updated one to your repo.
Note: We will test your project on the hammer server, so while it is not required that you
develop on hammer you should verify that your project builds and functions properly on
hammer.cs.ucr.edu.
Your project must also contain a names.txt file in the root directory which contains the name,
SID, and email of each of the partners in your group. It should have the following format.
Brian Crites, 860XXXXXX, bcrit001@ucr.edu
Andrew Lvovsky, 860XXXXXX, alvov001@ucr.edu
Do not wait to push your assignment to Github until the project due date. You should be
committing and uploading your assignment continuously. If you wait until the last day and can't
figure out how to use git properly, then you will get a zero on the assignment or be forced to use
the course late policy. No exceptions.
For late assignment submissions, a penalty of 10% will be deducted for every day the
assignment is late up to a maximum of 3 days, with exceptions only for documented
emergencies. For clarity, this means that an assignment that is 3 days late would incur a 30%
penalty to the grade assessed. Please submit this form along with your late submission.
Otherwise, the team will receive a zero on that assignment.
In addition to the above submission requirements you must update your README.md file so that
it specifies the current structure of your program. This is especially important since your final
program will likely be much different than what you originally designed in Assignment 1.Testing Your Submission
Your assignment 2 should have approximately the following structure, see the project structure
section for more details:
example-project-directory/
├── CMakeLists.txt
├── README.md
├── googletest
├── header
├── header_file_1.h
└── header_file_2.h
├── src
├── src_file_1.cpp
└── src_file_2.cpp
└── unit_tests
├── test_file_1.cpp
└── test_file_2.cpp
└── integration_tests
├── single_command_tests.sh
├── multiple_commands_tests.sh
├── commented_command_tests.sh
└── exit_command_tests.sh
You should also have a .gitignore and a .gitmodules hidden file in your root directory. Your root
directory should contain no C++ header or source files and your googletest directory should be
added to your project as a submodule. While the googletest directory is not required to be
present in the root directory it is suggested.
When testing your project we will run (approximately) the following commands on hammer:
git clone
cd
git checkout tags/hw2
git submodule init
git submodule update
cmake3 .
makeThese commands should generate a test executable as well as an rshell executable in the
root directory. Please run these commands on hammer with a brand new clone of your GitHub
repository to ensure your shell compiles and builds properly before submission.
Collaboration Policy
● You may not copy any code found online, doing so will result in failing the course.
● You may not look at the source code of any other student.
● You may discuss with other students in general terms how to use the unix functions.
● You are encouraged to talk with other students about test cases and are allowed to
freely share ideas in this regard.
Grading
10 Sufficient Unit Test Cases
10 Sufficient Integration Test Cases
10 Updated README.md
20 Single Command Execution
20 Command and Connectors Execution
20 Command with Comments Execution
10 Commands with Exit Execution
100 Total
Note: Your project structure is not explicitly listed in the grading schedule above but not
following the specified file names and location may result in losing points because the
automated grading system is unable to process your repository. Loss of points due to an
issue specified above are final and failure to build and compile will result in a zero for the
assignment.
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
辅导 comm2000 creating socia...
2026-01-08
讲解 isen1000 – introductio...
2026-01-08
讲解 cme213 radix sort讲解 c...
2026-01-08
辅导 csc370 database讲解 迭代
2026-01-08
讲解 ca2401 a list of colleg...
2026-01-08
讲解 nfe2140 midi scale play...
2026-01-08
讲解 ca2401 the universal li...
2026-01-08
辅导 engg7302 advanced compu...
2026-01-08
辅导 comp331/557 – class te...
2026-01-08
讲解 soft2412 comp9412 exam辅...
2026-01-08
讲解 scenario # 1 honesty讲解...
2026-01-08
讲解 002499 accounting infor...
2026-01-08
讲解 comp9313 2021t3 project...
2026-01-08
讲解 stat1201 analysis of sc...
2026-01-08
辅导 stat5611: statistical m...
2026-01-08
辅导 mth2010-mth2015 - multi...
2026-01-08
辅导 eeet2387 switched mode ...
2026-01-08
讲解 an online payment servi...
2026-01-08
讲解 textfilter辅导 r语言
2026-01-08
讲解 rutgers ece 434 linux o...
2026-01-08
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!