This tutorial provides a basic introduction to the software tools we suggest you use in this course. Read this material through first and then try out the instructions on the computer. Refer back to this material when necessary throughout the course. If you need help, ask a consultant or any of your instructors to show you how. Experiment with the computer outside the requirements of the course. It's fun and will make you more comfortable with the software required by the course.
UCS provides many handouts to help you learn about the computing environment at IU, and they ofer classes to help you get started with computers. Below is a list of pamphlets you might want to look at.
In this tutorial we explain what we believe to be the simplest and generally most satisfactory ways of accomplishing things, but there are usually other ways to do the same thing. For example, on UCS PCs telnet can be accessed from Windows as well as the menu access we describe below. In Windows the telnet font is smaller, but it is possible to switch to other Windows applications, such as Netscape, without leaving your telnet session.
You are encouraged to explore the wondrous complexities of our software environment, and in the process you will doubtless discover other approaches that you prefer at least some of the time. As in all things, this exploration should be pursued in moderation--don't neglect other aspects of life!
Skip the following Macintosh information for further instructions.
Now you will see a collection of icons, with one named copper and one named zinc; double-click the appropriate one. If the zinc icon is not present, you can still login to zinc by selecting some other icon, say the copper icon. Then select Open Connection from the File menu, and enter zinc in the Host/Session Name field of the dialog box that appears. In any case, the Telnet program will start up in a new window with the login prompt.
If you receive an Incorrect Password error, try typing your username and password again, slowly and carefully. If repeated attempts fail, see a consultant.
Once you've successfully entered your username and password, the computer prints out a welcoming message. If this is the first time you are using this account, then you will be prompted for a shell. We recommend that you select tcsh as your shell. (The chsh command can be used later, at any time, to change your shell, if you've already selected something else.) You should now see the UNIX shell prompt, which is either copper ~> or zinc ~>. (The ~ indicates you are in your home directory. The prompt will be modified accordingly if you move to another directory.) At this prompt you may enter any UNIX command.
On the PC you will be returned to the Communications menu, on the Macintosh you will be left in the Telnet program and then need to select Quit from the File menu to exit the telnet program.
UNIX commands may only be entered at the shell prompt. If a typing mistake is made, it can be erased with the Delete key. Each time you press the Delete key, the cursor moves one space to the left, erasing the character in that space.
copper ~> ls bin
Your home directory comes with an empty bin directory, that you will have no need for in this course. For now just keep it simple by staying in your home directory. After you've finished the tutorial below, try this command again. By then you will have created more files in your home directory.
There are a few more files in your account. These are "dot" files which contain information to configure your account. To see these files, you type
copper ~> ls -a
You will see a number of files such as .login and .profile. Do not delete any of these "dot" files.
cp .login test1.txt
You can name the copy anything you want, as long a name as you want. (Any letter or number may be used in a UNIX name, as well as some special characters such as dot.) UNIX, unlike some other operating systems such as DOS, is case sensitive: upper and lower case versions of the same letter are considered to be different. You should try to keep the extension after the dot the same, since that tells you what kind of file it is. Scheme files generally end in .ss and text files often end in .txt. You can see if the copy was made by entering the command ls. cp does not remove the original file.
To try this on your own, copy the file test1, which you just created, into a file test2.txt. When you type ls, you should see three file names: bin, test1.txt, and test2.txt.
mv test2.txt test3.txt
Now there should be no file test2.txt, and a new file test3.txt that is exactly what test2.txt was.
This deletes the file test3.txt from your directory. Be very careful when using this command; you may not be able to get the file back if you delete it accidentally.
The first shows you the contents of the file, one screenful at a time. Press the space bar to go from screen to screen. Hit return to move down one line at a time. Type q to quit (get back to the shell prompt) before the end of the file. cat scrolls through the whole file without stopping.
To print a file to a given printer, say cs_ps10, use the lpr command with the argument -Pcs_ps10. For example, to print text1.txt to the laser printer in LH004, type:
lpr -Pcs_ps10 save.txt
Sometimes many people print files at the same time. You can look at the list of files waiting to be printed using the command:
If you are picking up your printout immediately and the printer is not busy, you use the -h flag, which tells the printer not to print a header page with your name on it:
lpr -Pprinter-name -h filename
If you change your mind about printing a file, and it has not started to print, you can use the command lprm to remove it from the queue of files. You will need to specify the job number of the print job you wish to kill. You can get this number from the listing produced by the lpq command. Use man lprm to find out more about it.
copper ~> scheme Chez Scheme Version 4.1b Copyright (c) 1991 Cadence Research Systems > (+ 3 4) 7 >
When you press <CR>, Chez Scheme's read-eval-print loop evaluates the expression and prints the answer 7. Then you again get the prompt >. Enter 'cat, making sure you type the apostrophe before the word cat. Chez Scheme returns cat and then prompts with >. Chez Scheme is case insensitive. Regardless of whether quoted variables are entered in upper- or lower-case letters, Chez Scheme returns them in lower-case letters. Now enter 15 and we see that 15 is returned. Numbers need not be quoted when they are entered; they are self-evaluating. The symbol cat is not self-evaluating: we had to quote cat in order to have it interpreted literally as the symbol cat. Now enter cat without the quote. You get a message which tells you that the variable cat is not bound (don't worry about the "debugger" information for now, every error causes that to appear). cat, unquoted, is a variable that has not yet been given a value.
Now observe the results of entering each of the following expressions in response to the Scheme prompt. Can you explain the results in each case?
5 '5 cat 'cat (cat dog mouse) '(cat dog mouse) (+ 1 2 3 4 5) '(+ 1 2 3 4 5) '(car '(one two three)) (car '(one two three)) (cdr '(one two three)) (cons 'one '(two three))
We exit from Scheme and return to the shell prompt by responding to the Scheme prompt with
or by typing C-d. (This is our notation for control-d; hold down the control, or ctrl, key while pressing the d key.)
Giving emacs a filename argument, such as test.ss, causes emacs to load the given file for editing if it exists, or start a new buffer for creating the file if it does not exist.
You will now see a blank window with the cursor at the upper left corner and a banner at the bottom displaying Emacs and some other information such as (Scheme), indicating that the editor is in its Scheme mode.
(car '(one two three))
again and observe that when you close each pair of parentheses, the cursor bounces to show you the matching opening parentheses. The expression is not being entered in Scheme itself, so you will not see the result of its evaluation, but it can be sent to Scheme at any time, as we shall see. Press DEL (the delete key) and notice what happens: it erases the character to the left of the cursor.
We shall next learn to use the editing commands of Emacs. In Scheme mode emacs bounces the cursor for parenthesis matching and some other tricks that are great for Scheme programming, but not when you are typing prose (say in English). For that you want to be in text mode. We switch from the Scheme mode to text mode by pressing ESC (the escape key), releasing it, then pressing x. Note that M-x appears at the left end of the banner at the bottom of the screen. Now type text-mode<CR>. In the future, typing such a sequence will be indicated by M-x text-mode. (M-x is read "meta x". On some keyboards M-x may also be entered by holding down a meta or alt key while pressing x.)
Notice that now the word (Text) appears in the banner at the bottom of the screen. When you call up Emacs with a filename ending with the extension .txt, Emacs goes directly into Text mode, whereas when the filename has the extension .ss, it automatically goes into Scheme mode.
When entering emacs command names after the M-x (read "meta x") prompt, you can hit the space bar to cause Emacs to show you all the current completions of the command you are entering. This can save you from typing the whole command.
To move forward over one word, use the command M-f. (Recall this is read "meta f" and may be entered by pressing ESC and then f.) Next try M-b and watch the cursor move backward one word. You can abort a command or sequence of keystrokes with C-g. For example if you have typed ESC, but then decide that you want to move forward a character, enter C-g to abort the ESC keystroke, and then enter C-f. Try it.
Now enter C-e. The cursor moves to the right end of the current line. Entering C-a moves it back to the beginning of the current line. Two additional commands that you will find useful are C-v which moves ahead to the next screen and M-v, which moves back to the previous screen.
Below is a summary of the Emacs commands used in this tutorial. You will have a chance to use them in the assignment which follows the summary.
|C-f||Move cursor Forward one character. May use right arrow key.|
|C-b||Move cursor Backward one character. May use left arrow key.|
|C-n||Move cursor down to Next line. May use down arrow key.|
|C-p||Move cursor up to Previous line. May use up arrow key.|
|C-e||Move cursor to End of line.|
|C-a||Move cursor to beginning of line.|
|C-h||Enter the Emacs help facility.|
|DEL||Delete the character before the cursor.|
|C-d||Delete the character at the cursor.|
|C-k||Kill the rest of the line from the cursor to the end of the line.|
|C-y||Unkill (yank back to current cursor position) the last thing killed.|
|C-v||Display the next screen.|
|M-v||Display the previous screen.|
|C-x C-v||Load a new file into the current buffer. Prompts for a file name.|
|C-x C-w||Write the whole buffer to a file. Prompts for a file name.|
|C-x i||Insert file. Prompts for the file name.|
|C-x u||Undo the last text modification.|
|M-x run-scheme||Run Scheme in its own emacs window.|
|M-x text-mode||Enter text mode.|
|M-x scheme-mode||Enter Scheme mode.|
|M-x shell||Start a UNIX shell in an emacs window.|
|C-x m||Send an email message.|
|C-x C-c||Exits from Emacs.|
As time goes on, you will probably want to become familiar with more Emacs commands to speed up your work and allow you to do more things. There is a more complete GNU Emacs Reference Card available from UCS.
Tutorial, Part II