The project requires the use of more Unix systems facilities. Design and implement a simple UNIX shell program using the grammar specified in the later part of this section. Please allow for at least 100 commands in a command line and at least 1000 arguments in each command. In addition to the above, the following are required: 1) Reconfigurable shell prompt (default %) 2) The shell built-in command pwd 3) Directory walks 4) Wildcard characters 5) Standard input and output redirections > and < 6) Shell pipeline 7) Background job execution 8) Sequential job execution 9) The shell environment 10) The shell built-in command exit 3. Self-Diagnosis and Evaluation a. a list of features that are fully functional. Prompt is implemented with default prompt as “%” Shell built-in pwd is fully functional Shell built-in cd is functional Wildcards “*” and “?” is functional using glob Standard input and output redirection < and > are implemented and functional Background execution using & is functional Sequential execution using ; is functional Parent and child function works Shel built in exit works 4. Discussion of your solution: The shell project is implemented according to the requirements given to us and all the requirements are fully functional.
Strengths: o Meets all the requirements o Fully functional o No errors or warning o Program compiles Limitations: o Execute job 1 2 3 are taken from the third party source ad=nd edited according to what we need. The link: . 5. Test evidence: All the tests conducted are according to the marking guide provided to us. Basics:
1. Command line arguments using ./show 2. Testing command “ls” and “ps” Built-In Commands 3. Prompt & pwd
4. CD 5. Exit
Long Commands ./show ls -l -t a b c ./show a bb ccc dddd 1 22 333 4444 55555 666666 ./show all alphabets counting from 1 to 20
Wild Cards 1. ls -l /tmp/*.c ls -l /tmp/a*c, ls -l /tmp/abc.? Ls -l /tmp/*.? 2. ls -l /dev/*
Sequential execution ";" sleep 10 ; echo hello sleep 10 ; ls –l sleep 10 ; echo hello1 ; sleep 10 ; echo hello2 Sleep for 10 seconds before giving the output for ls -l Outputs the result for ls -l
Concurrent execution "&"
echo hello & echo world sleep 10 & echo hello ps & ls sleep 10 & Standard input redirection "<": cat < /tmp/foo
grep line < /tmp/foo Standard output redirection ">": ls -l > /tmp/junk cat /tmp/foo > /tmp/junk2 Simple shell pipeline:
cat /tmp/foo | cat cat /tmp/foo | grep line cat /tmp/foo | sort cat /tmp/foo | sort -r Long shell pipeline: cat /tmp/foo | sort | sort –r | grep line cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat
cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | cat > junk cat | cat | cat | cat | cat | cat | cat | cat | cat | cat | grep line Combinations: Check:
ls -l > junk ; cat < junk ; /bin/ls -lt /dev/tty* | grep tty | sort | head > junk2 & sleep 10 ; cat < junk2 ls –lt | cat > junk ; ps | sort & echo ps-output ; sleep 10 & echo wait-for-10seconds ; cat junk | cat | grep a | sort -r
Ignore Ctrl-C, Ctrl-\ and Ctrl-Z: Check whether the shell ignores SIGINT, SIGQUIT and SIGTSTP by typing Ctrl-C, Ctrl-\ and Ctrl-Z from shell prompt.
You've reached the end of your free preview.
Want to read all 37 pages?
- Summer '15
- main function, Command-line argument