----------------------- Exercise #5 for DAT2330 due October 1 ----------------------- -Ian! D. Allen - idallen@idallen.ca Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Global weight: 1% of your total mark this term Due date: 12:00 noon Wednesday, October 1, 2003. The deliverables for this exercise are to be submitted online on ACADUNIX using the "submit" method described in the exercise description, below. No paper; no email; no FTP. Late-submission date: I will accept without penalty exercises that are submitted before 10h00 (10am) on Friday, October 3. After that late-submission date, the exercise is worth zero marks; but, it must still be completed and submitted successfully to earn credit in the course. Exercises submitted by the *due date* will be marked online and email sent to you after the late-submission date. A sample answer will be posted online after the late-submission date. Exercise Synopsis: This week you will set up your own directory to hold your own executable programs and commands, and you will write another short shell script. References and Readings: Running Linux: Chapter 4, Lectures, online Notes. Where to work: Do your Unix command line work on the ACADUNIX computer. You can find a copy of all the Notes files on ACADUNIX under this directory: ~alleni/public_html/teaching/dat2330/03f/notes/ You can copy files from this directory to your own account. Exercise Details: 0. Did you read this week's notes yet? Read first; type second! 1. On ACADUNIX, create a directory named "bin" under your home directory. 2. Move the executable argv.sh script (see last week's notes and exercises) into this new bin directory. Make sure the script is an executable file. 3. Edit the file .bashrc in your home directory. (You may have created this file already.) Add the following lines to the .bashrc file in your home directory: PATH=$PATH:$HOME/bin export PATH echo "Your new path is: $PATH " The shell variable $HOME always contains the absolute pathname of your home directory. You are adding a new directory to your search path. Save your new .bashrc file. 4. Start up a new copy of bash on ACADUNIX. Confirm that you see the output of the echo command. (If not, go back and check your work.) 5. Comment out the echo line in your .bashrc so that it is a comment and does not execute any more. (We don't want to see this every time we start up bash!) 6. Make another new, *empty* directory somewhere in your account. You may use any name you like. 7. Move into the new empty directory you just created. (i.e. Make the empty directory you just created your current working directory for this week's exercise.) 8. Verify that you are in the empty subdirectory you just created. Stay in this subdirectory. The outputs of your scripts and commands should create files in this new subdirectory (not in your home directory). 9. Type this into your bash shell: $ echo $PATH Confirm that your own bin directory is at the end of the PATH line. When you have confirmed this, type this command line: $ argv.sh one two You should see the output from the argv.sh program, even though there is no argv.sh program in the current (empty) directory. The shell will search the PATH directories and find the argv.sh program in your own bin directory. 10. Produce a long listing (including hidden files) of your new bin directory and save the output in a file named binout.txt in the current (empty) directory. Do not change directories! Use a relative pathname to reach the bin directory, starting from the current (empty) directory. 11. Put a copy of the command line you used to do the above into a shell script file named listbin.sh in the current directory. (Do not put the redirection part of the command line into the script; copy only the part of the command line without the redirection.) Edit the file to add the path to /bin/sh as the first line. (Copy the exact /bin/sh line from the first line of last week's script. Your listbin.sh file will have two lines now.) Add your Assignment Label to the script as comment lines, below the /bin/sh comment line. (The /bin/sh comment line must always be the first line in the script!) Below your Label, add this line to set the search path for the script: PATH=/bin:/usr/bin ; export PATH The script will have exactly two lines that are NOT comment lines. Make the script executable. Test that the listbin.sh script produces the correct output. (Suggested method: Run the script and redirect the script output into a temporary file. Use the "diff" command to compare the temporary file with the binout.txt file that you created in the previous step. You should see no differences.) 12. Put another copy of an updated Assignment Label in file README.TXT. (The file name is all upper case.) In the Comment field, put the absolute pathname of the new directory you created to do this Exercise. 13. Submission. Submit all these files (at the same time) for marking as Exercise 05: .bashrc binout.txt listbin.sh README.TXT (Not all these files are in the same directory. You will have to specify Unix pathnames to reach them all on the submit command line.) For Exercise 05, always use "05" as the first argument to "submit". Always submit all the files at the same time; do not use many different submit commands. Use one submit command with all the required pathnames.