This is the preamble and three script questions from the Third Unix Test. -IAN! idallen@ncf.ca June 2001 Part A: Unix work You will need to be running Floppix with networking to do some of this test. You must have network access to use tel- net and ftp to reach the machines mentioned in this test. The IP address of the Test Machine is 205.211.47.76. The test_two directory used in some of the scripts, below, is a sub-directory of your HOME directory on the Test Machine. This directory will be created by your instructor before you start your test. Your directory test_two is where you must put your scripts and your script output if you want the instructor to mark them. Your scripts do not have to create this directory; you may assume it exists any time a script specification requires you to use it. Only scripts and output found under directory test_two on the Test Machine will be marked. Only correctly-spelled script and file names will be marked. Your scripts must start with a valid Script Header, as given in class and in the Week 7 notes. You do not have to detect or handle errors in the scripts you write on this test. Error handling will be covered in Chapter 11. For example, your script does not need to check to see if a file or directory already exists before it tries to make one. Many of the scripts you write during this test will not run without errors if you run them twice; because, the scripts will have created files and/or directories and a second attempt to re-create the same files and/or directories may generate error messages. Make sure you clean out the results of one script run before you test your script a sec- ond time. Unix Task A - Marks: 4 On the Test Machine: Write an executable shell script named 1_create_it_is_raining.sh that will do the following actions (in this order): 1. Display the current date. 2. Put the four-word sentence It's "raining" $20 bills! into a new output file named it_is_raining.txt in the current directory. Copy the sentence and all punctua- tion exactly! 3. Set the permissions on the output file to be (a) read for owner, (b) read and write for group, (c) nothing for others. Test your script in your test_two directory and leave the output file for marking. Unix Task B - Marks: 9 On the Test Machine: Write an executable shell script named 2_dotdir_maker.sh that will do the following actions (in this order): 1. Change to the HOME directory of the person running the script. 2. Display the new current working directory. (This must be the HOME directory of the person running the script.) 3. Change to the test_two sub-directory located under the (new) current directory. (You may assume this sub- directory already exists; no error checking is needed.) 4. Display the new current working directory. 5. Create a sub-sub-directory named .dotdir in the (new) current directory. (You may assume that the sub-sub- directory doesn't already exist; no error checking is needed.) 6. Sort the file /etc/passwd in reverse order, and put the output into a file named passwd_sorted.txt inside the .dotdir directory. (Do not change working directories to do this operation.) 7. Set the permissions on the .dotdir sub-sub-directory to be: (a) read, write, and execute permissions for the owner, (b) write and execute permissions for group, and (c) execute only permissions for anyone else. (Do not change working directories.) Test your script in your test_two directory and leave the output for marking. Unix Task C - Marks: 11 On the Test Machine: Write an executable shell script named 3_tree_link_maker.sh that will do the following actions (in this order): 1. Create a sub-directory named top in the current direc- tory. 2. Under the newly created top directory, create two sub- sub-directories named one and two. 3. Under the one sub-sub-directory, create two names: (a) Build this command pipeline: Run the rusers com- mand with a single argument that is the AIX Unix machine name (use the full Internet domain name); translate blanks to newlines; select only the first 5 lines; and put the selected output into a file named today (b) create a second name for this output file called aujourdhui (French for "today"). 4. Under the two sub-sub-directory, also create two names: (a) Build this command pipeline: Get a list of your Unix processes (use the "f" option for best results); select from the output only the lines that contain the string that is the first command line argument to this script; and put the selected output into a file named processes (b) create another name in this directory for the file containing the previous rusers pipeline output and call the new name heute (German for "today"). This will be the third name for the same file. 5. Rename the sub-directory top to have the two-word name (including a space) my junk. 6. Delete the entire my junk sub-directory and all its contents, leaving nothing behind. To be safe from script errors, test your script in an empty directory. This script should leave nothing behind. You may want to leave off the "delete everything" step until you are sure that your script creates the correct format sub-directories!