Vous êtes sur la page 1sur 1

PROGRAMMING ASSIGNMENT

SYSTEM PROGRAMMING – CS 421


Due Date: Tuesday, May 17, 2011

Problem Statement
The purpose of this assignment is to give you practice in the use of UNIX system calls and writing a command
interpreter on top of UNIX. You will implement a small UNIX shell called cs421shell of the specifications given
below:
 The shell should have a prompt. The prompt will be your roll number followed by a :- e.g. BSCSF08M001:-
 It should accept commands, interpret them, execute them, and then redisplay prompt for the next command.
 The shell should terminate on receiving EOF (<Ctrl-D>). It is not acceptable for it to terminate upon receiving a
signal such as SIGINT (<Ctrl-C>).
 The shell will implement four `intrinsic' commands: cp, mv, rm, finfo:

o my_copy source_file target_file Copy source file to target file

o my_move source_file target_file Move a file

o my_remove file Remove a file

Display type of file (simple file, directory, etc.), file size, permissions,
o my_info file owner's ID, and the number of blocks allocated to file.

In all the above commands it should be possible to specify the path of a file if it is not in the current directory and also
handle conditions when the user enters invalid file names or tries to read/write files he/she does not have permission to
access.
Marks Distribution:
 Ignore SIGINT (<Ctrl-C>) [10]
 Print prompt. [5]
 Get input and terminate on EOF (<Ctrl-D>). [10]
 Carry out (i.e., decode and execute) commands. Implement a simple parser to recognize "my_copy", "mv_move",
"my_remove", and "my_info" (file info) as the first words of any set of input. If recognized, carry out the
appropriate command by using your OWN code and NOT by calling exec(). For all the remaining external
commands you should use fork(), exec() sequence. [50]
 If the first word of any input is not "my_copy", "mv_move", "my_remove", or "my_info", only then you can use
exec() system call. [10]
 Maintain a history list of the past 20 commands entered by the user and allow the user to access the commands in
the history list with the ! operator. !N means execution of the command which is N commands before the last
command such as !1 for executing the second to the last command. [15]
 You must use UNIX system calls to perform all file-related operations such as open, read, write etc. You will not
use fopen(), fprintf(), fgets(), fputs() etc in this assignment.
 Testing is one of the most important considerations for any project. It should be possible for your shell to
automatically run a list of commands from an input file by using the following input parameters: [Bonus]
cs421shell -f input_file
cs421shell should terminate at the end of the input file.
Submission Instructions:
 You have to submit your assignment in Soft Copy Only. The assignment directory (bcsf08axxx) should contain
necessary program files named as myshell.c, readme.txt, and a script.sh file. Remember the permissions on all
the files in your assignment should be 666 and on all the directories and sub directories should be 777. You need
to make an archive of the final directory and copy the archived file in the secure shell server (172.16.0.21) in the
/home/faculty/arif/f08m/ or /home/faculty/arif/f08a/ directory (what ever applies to you)
 The dead line for copying the assignment to the secure shell server's directory is by 3:00 pm, Tuesday, May 17,
2011.
 NO late submissions will be accepted for this assignment. If you are planning a leave on the D-Day, you may
upload your assignment a day before the D-Day. So start doing the problems from today so that you can submit
your assignment in time.
TIME IS JUST LIKE MONEY.
THE LESS WE HAVE IT;
THE MORE WISELY WE SPEND IT.
Manage your time and Good Luck
ARIF

Vous aimerez peut-être aussi