Out: Groups A & B: Feb 6 C: Feb 9 Due: Groups A & B: Mar 6 C: Mar 9 Midterm: During the lab, Feb 21 and 24 32 marks/marked out of 30.CENG251 – Assignment #3: A Command Shell, ...

dont worry about demonstrating program in first lab


Out: Groups A & B: Feb 6 C: Feb 9 Due: Groups A & B: Mar 6 C: Mar 9 Midterm: During the lab, Feb 21 and 24 32 marks/marked out of 30. CENG251 – Assignment #3: A Command Shell, The Little Functions 1. A time log following the format of the 1st two labs is required. (3 marks) 2. Create a command shell based on commandServer2.c that recognizes the following commands and calls appropriately named stub routines for each of them. Hand in a separate listing and set of tests that shows that the appropriate routine is called . Create the stubs in a separate file that is included with your main and interpret routine. DO NOT IMPLEMENT THE FUNCTIONALITY OF ANY OF THESE METHODS AT THIS STAGE. The only thing a stub routine should do is return a string “This functionName is not yet implemented” in order to identify which function was called. (4) Use a lookup table to find each command. If the command isn’t in the list respond with “commandname not found”). a. export var=value unset var b. chdir dirname (3) c. access file1 file2 file3 …… (2) d. chmod octalPermission file1 file2 file3 …. (3). e. path file1 file2 file3 …. (3) f. touch -m time1 -a time2 file1 file2 file3 … (3). g. ln -s -f file1 file2 (3) Demonstrate this program in the 1st lab. 3. Implement a 2nd version of your program which implements the following using C functions a. Instead of “command not found”, if your interpret routine does not find the command have the C system call execute it and use the return code from the system call to display the status of the command. (2 marks) b. export name=value (2 marks) unset name Set the environment variable name to the value. Verify that name is set by issuing a echo command which, since it’s not in the list, will be executed by system in a sub shell. An unset variable will display nothing when you attempt to echo it. c. chdir dirname (3) Change your cmdline prompt so that it always shows the current directory. (1) Have your function use the C chdir function to change directories and test by issuing a command to (1) Testing: i. Change to an absolute directory path ii. Change to a relative directory iii. Attempt to change to a directory that doesn’t exist. iv. Have your program use perror to display an error message if chdir fails. (1) d. access file1 file2 file3 … (2) Use the access function to test and report each of the 4 access properties separately for each file. If the file does not exist then only do that test and ignore the others. e. chmod octalPermission file1 file2 file3…. (3) Use sscanf to convert the octalPermission string to a number. Use the C chmod function to change the permissions of the files. If chmod fails use strerror to report the problem. Verify that the changes took place. f. path file1 file2 file3 (2) Display the realpath (full name), dirname and basename of each file. Your test cases should have g. touch -m t1 -a t2 file1 file2 file3 …. (4 marks) i. Implement a small getopt loop in your function to implement this command. Set the default times for the modify and access flags to the current time – seconds since the epoch. Use the getopt loop to capture -m t1 and -a t2, if they are present where t1 and t2 are large integers representing ii. Verify that each file exists. 1. If it does use utimes to set both times 2. If it doesn’t,, use creat to create it, verify that you were successful, use futimes to set both times and then close the file. 3. Verify using the stat command that you were successful. h. Link -s -f file1 file2 (4) In your function write a getopt loop to capture the -s and/or -f flags if they are present. If the -f (force) option is present use the appropriate “little” function to delete file2. If the -s (symbolic) option is present use the appropriate “little” function to create a hard link. Itemize your test cases and report on how successful you are. 4. Since your program should be based on commandServer2.c you can create a log of your testing in the file shell.log. Use the shell command: truncate - -size 0 shell.log create an empty file. Perform a test of all of your commands in sequence, including commands not implemented, and a sample bad command to test your shell. Use comments to indicate what you are testing. Hand in your log with your report. If you made some mistakes you can edit the file before handing it in. Summarize what was successful and what was not. (3 marks)
Mar 11, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here