CISC361-010 Project 2

Assigned: March 16, 2009, Due: April 27, 2009
(set April 20, 2009 as your due date and it's like a week extension)

Adding some features to the shell

Objective

In this project you will be adding more functionality to your shell from project 1. So the first step is to get your shell from project 1 working, or at least enough to implement features for this project, if it doesn't already work. Features that you will implement include being able to background processes, file redirection and piping (IPC). Another objective of this assignment is to introduce programming with POSIX threads (pthreads). Experience with some more system calls and C library functions will also be done to hone your programming skills. Reading of man pages will also be a must to do well.

The Assignment

Test Runs

Test your shell by running the following commands in it (in order):

    pwd
    ls &
    ls -l &
    cd /
    sleep 20 &
    ls & 			; run before sleep is done
    pid
    tty
    /bin/ps -lfu USERNAME	; replace USERNAME with your own  
    cd
    cd [project test dir of your choosing]
    pwd
    ls -l
    rm -f mail1 mail2
    touch mail1			; create this file
    watchmail mail1
    echo hi >> mail1
    echo HiThere > mail2	; create another file
    watchmail mail2
    echo there >> mail1
    echo Subject: >> mail2
    cat mail1
    cat mail2
    watchmail mail1 off
    echo bye >> mail1
    echo bye >> mail2		; still watching this one

    rm -f test1 test2 test3 test4 test5 test6 test7 test8
    test-1+2 > test1
    test-1+2 >> test2
    test-1+2 >& test3
    test-1+2 >>& test4
    cat test1 test2 test3 test4
    test-1+2 > test1
    test-1+2 >> test2
    test-1+2 >& test3
    test-1+2 >>& test4
    cat test1 test2 test3 test4

    noclobber				; turn noclobber on
    test-1+2 > test5
    test-1+2 >> test6
    test-1+2 >& test7
    test-1+2 >>& test8
    cat test5 test6 test7 test8
    test-1+2 > test5
    test-1+2 >> test6
    test-1+2 >& test7
    test-1+2 >>& test8
    cat test5 test6 test7 test8

    grep hello < test7
    grep error < test7

    rm -f test9 test10 test11 test12
    noclobber				; turn noclobber off
    test-1+2 > test9
    test-1+2 >> test10
    test-1+2 >& test11
    test-1+2 >>& test12
    cat test9 test10 test11 test12

    ls | grep test                   ; show pipes works
    ./test-1+2 | grep  hello
    ./test-1+2 |& grep hello
    ./test-1+2 | grep output
    ./test-1+2 |& grep output
    ./test-1+2 |& grep error

    pid                                        ; zombie avoidance checking
    /bin/ps -lfu USERNAME | grep defunct       ; replace USERNAME with your username
    
If your file redirection doesn't work then use another shell to modify your mailfiles to test your watchmail command. The TA will also test each feature.

A sample of what the output should look like is here. Be sure that your code compiles and works on both Solaris and Linux.

Grading

Turn In

Turn in all of your code, a script of the test runs (show doing a `make clean' followed by a make to build your shell) for your well documented program. Turn in one connected packet of paper with no blue sheets. Your name should be clearly visible on the first page you turn in and at the beginning of each source file.

Also, you need to tar up your source code and email it to the TA so that your shell can be tested some more. To do this do the following (assuming your code is in a directory named proj2):

cd ..../proj2
make clean
cd ..
tar cvf YourName_proj2.tar proj2
To verify that your files are in the tar file take a look at the table of contents of the tar file like:
tar tvf YourName_proj2.tar
Then upload the file to Sakai. Also turn in a copy of your test runs at the beginning of class on the due date for full credit. Remember that only code received/turned in can be graded. Late penalties will be given based on the timestamps of Sakai upload.