Follow the directions of the DDD tutorial available online at http://heather.cs.ucdavis.edu/~matloff/Debug/Debug.pdf. Each person must do the tutorial individually. The authors.txt for the partner that is only submitting Ins.c should contain only one name. You will find Ins.c in ~ssdavis/40/p2. When done completely debugging Ins.c, handin it.
There are at least four ways to gain access to ddd:
1. Go to the basement of Kemper and select DDD Debugger from the Programming menu.
2. To use ddd at home under Windows, on programs developed at home.
2.1. Install cygwin (available for free from cygwin.com) with g++, openssh, and ddd. The selection of ddd should automatically install the X windowing server for cygwin.
2.2. Once cygwin is installed, type xinit& at the cygwin command prompt to open an X window, and then type ddd
at the prompt.
3. To use ddd at home under Windows, on programs developed in the CSIF.
3.1. Install cygwin with at least the X server (I would still suggest installing g++ and ddd).
3.2. Once cygwin is installed, type xinit& at the cygwin command prompt to open an X window.
3.3. Type ssh –X username@CSIF_computername
3.4. Once you have logged into the CSIF computer, change to the appropriate directory, and then type ddd&
4. To use ddd at home under MacIntosh OS X, on programs developed in the CSIF
4.1. Open an X term. (See the MacIntosh help to install the X package)
4.2. Type ssh –X username@CSIF_computername
4.3. Once you have logged into the CSIF computer, change to the appropriate directory, and then type ddd&
Bash Shell Scripts (50 points)
Each script must use the bash shell, so use "#! /bin/bash" as the first line. A good tutorial is at http://steve-parker.org/sh/sh.shtml
1. (7 points) Write a shell script, named grepdir.sh, that searches for a pattern in a directory, and all of its subdirectories.
The starting directory is the first argument, the pattern is the second parameter, and the options for grep are all succeeding parameter(s). Options will start with a hyphen. The script should produce a usage statement if the script is misused.
2. (8 points) Write a shell script that copies the files in two directories dir1 and dir2 (supplied as the first two arguments), to dir3 (supplied as the third argument). If dir1 and dir2 contain the files with the same name, then the newer file should be copied to dir3. This does NOT look at the subdirectories of dir1 and dir2. Dir1 and dir2 must be existing directories, and dir3 may not be an existing regular file. The script should produce a usage statement if the script is misused. Name your script cpdirs.sh
[ssdavis@lect1 private]$ ls -lR
.:
total 24
-rwx------ 1 davis users 533 2010-01-10 14:59 cpdirs.sh
-rwx------ 1 davis users 395 2010-01-10 14:39 grepdir.sh
-rwxr--r-- 1 davis users 980 2010-01-10 12:19 makemake.sh drwxr-xr-x 2 davis users 4096 2010-01-10 15:01 temp
drwxr-xr-x 2 davis users 4096 2010-01-10 15:04 temp2
-rwx------ 1 davis users 384 2010-01-10 12:17 uncomp.sh
3. (14 points) Write a shell script called uncomp.sh that will take a file with the standard archiving and compression extensions (gz, zip, tgz, and tar) and perform the appropriate operation[s] to uncomp.shress and unarchive the files. Acceptable filename extension combinations are .tar, .tar.gz, .tgz, .gz, and .zip. If the filename doesn't have one of these extensions then your script should print a usage statement. An example of this script is provided below. The usage is "uncomp.sh {filelist}+"
5. (21 points) (30 minutes) Write a Bash shell script, makemake.sh, that will create a makefile called Makefile based on all the .cpp files in the current directory. If a .cpp file has any #includes of non-system header files (those with double quotes around them), then those files should be listed in its dependencies. The –Wall –ansi, and –g options will always be used with g++. The shell script takes the name of the executable as its first argument. If no argument is provided, the script should report the error, and print a usage statement. All other parameters are additional options that should be used with every call to g++. The Makefile should end with a "clean:" routine that removes the executable and all object files. (Hints: the -n option of echo inhibits the default newline, and \t and \n work with echo. I used sed and awk to get at the name of the header files within the .cpp files.)