Systems Practical 2 Files, Editing, & Submitting

Systems Practical 2 Files, Editing, & Submitting

Systems Practical 2 Files, Editing, & Submitting∗ Roger Burroughes This practical consists of three sections: • how to edit text files with Emacs • how to submit assignments electronically • how to use file permissions and related utilities Note, however, that it is important that you should complete the “submit” section of this practical. Leave yourself time to do this — even if it means not completing the other sections (although it is in your interest to try anything later, in your own time, that you do not finish in the lab session). ∗Version for 2006/2007 1 Editing Text With Emacs This section will give you some practice in using Emacs. It is divided into two parts: • The first section allows you to try out some of the Emacs commands described in the systems lecture. • In the second section, you will put these commands into practice by editing some text. Either by using some supplied text (a poem by Robert Burns), or by creating your own text (for example, by making notes on some aspect of the course, or on the emacs tutorial itself). Emacs Tutorial Choose one of the following methods to run the Emacs tutorial: Method 1: 1. Make sure you are in your home directory (type “cd” to return to your home directory if you’re not sure — and then “pwd” to check), then make a copy of the Emacs Tutorial, rename it and put it in your home directory as follows: cp ˜infteach/system/emacs-tutorial my-tutorial This takes a copy of the file emacs-tutorial, renames it my-tutorial, and places it in your home directory (assuming you are in your home directory, or have used “cd”). 2. Open the tutorial in Emacs by typing: emacs my-tutorial and work through the tutorial to the end. If there are any problems with, or comments on, or questions about the tutorial, make a note of them. Method 2: 1. Start emacs from the command line (just type “emacs” at the Unix prompt and hit “Return”) or Select “Emacs Text Editor” from the “Applications ⇒ Programming” menu. 2. Select “Emacs Tutorial” from the “Help” menu at the top of the Emacs window. To Quit: 1. When you’ve finished, type “Ctrl-x, Ctrl-s” to save it1, then “Ctrl-x, Ctrl-c” to quit. Practice In Using Emacs Make a copy of ˜infteach/system/poem in your home directory (use “cp ˜infteach/system/poem poem” from the command line — this will make a copy in your current working directory). Once you have done this, open the file with Emacs: % emacs poem 1If you selected the “Emacs Tutorial” from the “Help” menu, the file will be saved as “TUTORIAL” in your home directory. 2 (note that you get a new Emacs window, and no return of the Unix prompt in the invoking terminal window - you won’t get the prompt back until you quit Emacs). 1. You will see that the underlining of the title is mis-aligned. Move the cursor (using the mouse or emacs command keys) to the second line and insert the appropriate number of spaces in front of the underlining. If you put in more spaces than you meant to, you can remove the surplus with the “←−” (Backspace) key. 2. The first line of the seventh stanza (line 34 of the file) is incomplete. At the moment it reads: They’ve ta’en a weapon, and , It should read: They’ve ta’en a weapon, long and sharp, Insert the necessary words (use “Ctrl-U 3 4 Ctrl-N”2 to go to the correct line — assuming the cursor is at the top of the file, or use the mouse and cursor keys). 3. The eighth stanza is full of spelling mistakes — go through and correct them all (use spell-checking for this — see under “Other Useful Commands” in the reference section of the lecture notes). 4. The second last stanza has some (obvious!) rubbish at the end of it, so remove everything from “All of the next...” to “end of the junk”3. 5. The second and third stanzas are in the wrong order. Select the text to be moved (the second stanza and the blank line below it) by moving the cursor to the start of the second stanza, click and hold down the left mouse button, and drag the cursor down to the end of the stanza and release the button — you should see the text highlighted as you move, and it should stay highlighted when you release the mouse button. The highlighted lines are a “region”, and can be cut out of the file with “Ctrl-W”. You can then move the cursor to the first line of the fourth stanza and paste the text back in with “Ctrl-Y”. If you move the cursor after cutting, and before pasting, you can move regions of text around the file Take a look at the “Edit” menu. The “Cut” and “Paste” commands just used are duplicated here, as well as two related commands: • Copy lets you duplicate the selected region by making it available for pasting without having to cut it first. • Clear lets you remove the selected region by cutting it without making it available for pasting. Notice how the menu items are greyed out: they are not available for you to use when there is no region highlighted. There’s also the very useful “Undo” command in the “Edit” menu that will undo your last editing command. • Make some comments on your experiences with the Emacs tutorial, using any notes you took during the work-through above (or make some up — we only need text to type here!) Once you’ve finished, save your file and exit Emacs (see the “To Quit” section of the “Emacs Tutorial” section above). 2This is how you give a numeric argument, in this case “3 4” (for 34). The next command or keystroke is executed this number of times, in this case “Ctrl-N” (next line) so the cursor moves down 34 lines. 3Note that entire lines can be deleted with “Ctrl-K” (assuming you’re at the start of the line — otherwise “Ctrl-K” just deletes from the current cursor position to the end of the line). 3 Electronic Submission of Work This section demonstrates the “submit” command, used to submit coursework electronically. The requirement here is simple — to successfully use the submit command to submit the results of the Emacs4 practical. Once you have completed your work, and created a file containing your submission (let’s — for the sake of this example — call the file “submission”), you need to submit it with the submit command, and you will require the exercise (or practical) name (or code). For this exercise, the code is “se1” — the command should therefore be5: % submit inf1 inf1a se1 submission If you just type the command “submit” you will be given a list of the valid options (in the output below, long lines are truncated): % submit submit 2.63.1-1.dice.0 usage: to submit an exercise: submit <year> <course> <exercise-number> <file1> <file2>... where the <exercise-number> is some integer and <file> can be a regular file or a directory. You need to specify which year you are in. Valid ’Year’ choices are: msc (courses: vis-5 tts-5 tm-5 tdd spnlp-5 rl propm ppls-5 ... inf2 (courses: inf2d inf2c inf2b inf2a) inf1 (courses: inf1b inf1a) cs4 (courses: vis-4 tpl slip qsx ppls-4 pa-4 ms-4 hci-4 fpl... cs3 (courses: st seoc sdp pi os lsi ip fps ec dbs ct cs com... cs1 (courses: cpmt cp1 cl1) cg1 (courses: hc1 fmcs1) ai4 (courses: tts-4 tm-4 spnlp-4 masws-4 lfd-4 kmm-4 iar-4 ... ai3 (courses: pi lp kre ivr ics icl gagp ailp abs) test (courses: test5 test4 test3 test2 test1) SUBMISSION DID NOT HAPPEN! % If you get the exercise name (practical code) wrong (and can you see what’s wrong with the incorrect example command below?), you will see the following: % submit inf1 inf1a se2 submission submit 2.63.1-1.dice.0 usage: to submit an exercise: submit <year> <course> <exercise-number> <file1> <file2>... where the <exercise-number> is some integer and <file> can be a regular file or a directory. The exercise name should be one of: se1 fp4 fp3 fp2 fp1 cl4 cl3 cl2 cl1 for course inf1a of year inf1. 4If you do not complete the Emacs part of this practical, submitting any text file will do – the important thing is to successfully use the submit command, not what you actually submit! 5In these examples, the Unix prompt is represented by the % symbol. 4 SUBMISSION DID NOT HAPPEN! % Note that submit will always tell you if the submission completes or fails — you will see either “SUBMISSION DID NOT HAPPEN!” or “Submission... succeeded”. Using the earlier example (a file called ’submission’ from the home directory ’/home/infteach’, for the module ’inf1a’ and year ’inf1’, with exercise number ’se1’) we should see: % submit inf1 inf1a se1 submission Submit the following for exercise se1, module inf1a of the inf1 course. /amd/nfs/pegasus/disk/ptn041/infteach/submission Is this correct (y/n: n aborts)? y Submission of the following for exercise se1, module inf1a of the inf1 course succeeded: /amd/nfs/pegasus/disk/ptn041/infteach/submission % Note that you may see either the long or the short version of the pathname for your file echoed back in the response (in this example, either /amd/nfs/pegasus/disk/ptn041/infteach/submission or /home/infteach/submission). Either is OK — they both refer to the same file.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us