========================== CST8129 Challenge Projects ========================== -IAN! idallen@ncf.ca Here are some "challenge" projects that I think the more advanced students should be able to do without too much trouble. These aren't worth any marks; but, they are worth experience points. I think you can do these things with minimal coding (and maximum RTFM). If you are working on any of these projects, let me know. I'd like to see how you solve them. *) Modify simpleshell.c and add a built-in "exit" command that calls the C exit() function to exit the program. (Bonus: if there is a command line argument, convert the character string argument to an integer using strtol() and pass that integer as the first argument to the exit() function.) *) Modify simpleshell.c and add a built-in "cd" command that calls the Unix chdir() function with its one command line argument. (Make sure there is *exactly* one argument!) (Bonus: print an error message if the chdir() function fails.) *) Modify simpleshell.c and add a built-in "umask" command that calls the Unix umask() function. If there are no arguments, print out the current value of the umask (in octal, with leading zeroes, just as bash would do it). If there is exactly one argument after "umask", convert the string to an integer using strtol() (base: octal!) and pass the integer to the umask() function to set the new umask. *) Write a C program to read a file in DOS format and write it out in Unix format. (Convert CR+LF into just LF.) You could write it as a filter (read stdin; write stdout); or, you could accept a file name (e.g. "foo"), process "foo" into a temp file, rename the "foo" to "foo.bak" (using the Unix rename() function), and rename the temp file to be "foo". Check all the error returns from all the functions used. (Bonus: only convert CR+LF to LF; do not touch a CR if it isn't followed by a LF.) *) Modify simplepipe.c and remove the read() call and error checking from the child process, replacing it with an execlp() of the command "cat". Now try an execlp() of "wc". Now try "tr [a-z] [A-Z]" (that is the "tr" command with two arguments). You can copy the execvp() code from simpleshell.c and modify it to use execlp() instead of execvp(); or, you can keep using execvp() if you prefer. Make sure you copy all the error checking too. *) Modify simplepipe.c and remove the write() call and error checking from the parent process, replacing it with an execlp() of the command "date". Now try an execlp() of "who". Now try "echo Good Morning" (that is the "echo" command with two arguments). You can copy the execvp() code from simpleshell.c and modify it to use execlp() instead of execvp(); or, you can keep using execvp() if you prefer. Make sure you copy all the error checking too.