(Last Revision -- 08/11/99)

DOING THE "HELLO WORLD" PRACTICE ASSIGNMENT

DIRECTIONS:

Use this document as a tutorial to get accustomed to the class computing 
environment.  (This is NOT an assignment for credit.)

Read everything in this document before you start doing the tutorial it 
describes.

Quotation marks ("...") are used in this document for a variety of purposes.  
In several cases, it is done to indicate the exact characters you are supposed 
to type in order to give some particular command to the computer.  Generally, 
you are NOT supposed to include any quotes in what you type.  In the few cases 
where you ARE supposed to type quotes, the directions will say so explicitly. 

If you are supposed to press the Enter key after typing a command, the 
directions will use the word enter.  For example, 

Enter "vt100" 

means type "vt100" (without the quotes) and then press the Enter key.  

Commands typed while the editor JOVE is running are NOT usually completed by 
pressing the Enter key.

TUTORIAL:

1.  If you don't already have an account on the CS Dept Sun Ultra network, 
then get a user name and password from your instructor.

2.  Locate an available Sun Ultra computer, or personal computer you can 
telnet from.  Your instructor and/or a lab assistant can help you.

3.  The names of the Sun Ultra's are: altair, castor, pollux, rigel, vega, 
capella, regulus, soleil, zaurak, saiph, and spica.  If you are telnetting in 
from some computer other than a Sun Ultra, make a random choice and log in to 
one of the machines named above.  If you need help logging in, raise your hand 
or consult the appropriate section of the handout entitled "Gaining Access to 
Workstations in the Computer Science Department Network". (This document is 
available in the class gopher space under the file name "loginDirections".)

4.  To login, you enter your user name and password when prompted.  The 
password you type will not show on the screen.  This is normal.  It is a 
security feature that helps prevent others from observing your password.   

5.  If you are telnetting, then after you successfully log in, the system may 
ask you about your terminal type.  This means the system needs to find out 
what kind of terminal control codes are being used.  If you are asked about 
this, just enter "vt100".  Then wait for the shell prompt to appear.  

The shell prompt will be your user name, followed by an "@" sign, then the 
name of the host you are logged into, then a colon, and then a tilde.  For 
example, if your user name were "jdoe" and you were logged into zaurak, your 
shell prompt would be something like: "jdoe@zaurak:~".  This prompt means that 
the Unix shell program is ready to accept a command.

If you logged in at a console, wait until the graphic "desktop" appears.   
Then near the bottom of the screen, move the mouse arrow into the small square 
that is just to the left of the square containing the question mark (?).  Then 
move to the little triangle at the top of the square and click on it.  A menu 
titled "Hosts" should pop up.  If that doesn't happen, raise your hand to get 
some help.  Once you have the menu, click on "Console."  The menu will 
retract, and a new window will appear with a shell prompt as described above.  

6.  Optional step:  At this time, you can change your password by entering 
"nispasswd" at the shell prompt and then following the directions on the 
screen.

Before you enter the command, you must first think of a password that is at 
least 6 characters in length, contains at least two alphabetic characters and 
at least one numeric or special character.  

A password needs to be easy for you to remember but hard for anyone else to 
guess.  Unfortunately, it is likely that hackers will be trying to break into 
your account.  Basing your password on two unrelated words separated by 
punctuation is a good idea.  Examples:  greeni"dea, m0Le*pen.  Also you can 
think of a favorite saying and base the password on the use of the first 
letter of each word.  For example "A poem as lovely as a tree", could become: 
apaL,A1t.  Don't use any of these particular examples though, you need to make 
up a password known only to you.

7.  Enter "jove p1.cpp".  This tells the computer to run the editor called 
jove, and that you want to work on a file called p1.cpp.  If the file does not 
already exist, jove will create it.  Unless the file already exists, the 
window will now go blank, except for some documentation lines at the bottom.  
Jove is now running.  Type the following text.  It is a simple C++ source 
program.  If there is already text in the window, change it to the text below. 

#include <iostream.h>

int main ()
{
  cout << "Hello World!" << endl ;
  return 0 ;
}

8.  If you haven't done so already, consult the legend on your copy of: "Jove 
-- a quick reference guide" and figure out how to type codes like C-f or M-x.  
Now do C-x, C-\   The C-x, C-\ command causes a copy of the program you typed 
to be saved.  It is saved as a file named p1.cpp, because of the name you 
typed in step 7.  A C++ program for the g++ compiler on the Suns is supposed 
to have a name ending in ".cpp" or ".cc".  In other words, it should have a 
name such as p1.cpp, myprog.cc, prog3.cpp, and so on.  This is important.  If 
the ".cc"  or ".cpp" is missing, the compiler or linker may fail, even though 
the program has no errors.

9.  Now do C-x, C-c.  This exits the editor.  Next enter "g++ p1.cpp".

10. If you got an error message, it probably means that you made a mistake 
when you typed the program.  In that case go back to step #7 and fix it.  If 
there were no errors in your program, then your compilation succeeded, and the 
name of the executable translation of the program is "a.out".  In that case, 
enter "a.out", to execute the program.  You should see the message "Hello 
world!"  that your program prints on the screen.  If you see that, 
congratulations!  You just wrote a program and executed it successfully!

11.  Now that you are sure the program is working correctly, let's do another 
test.  This one will be "for the record". Enter "script p1.script" and wait a 
moment.  The command executes the script program.  The script program makes a 
record of whatever is typed in your console window.  The record is placed into 
a file with the name you specified -- p1.script.  When your prompt is written 
on the window again, you are ready to begin the recording.  Enter "a.out" and 
see your "Hello world!"  message written out on the window.  Now enter "exit" 
to turn off the scripting program.  From the time you entered "script 
p1.script" to when you entered "exit", all things that were written on the 
window (by either you or the computer) were also recorded in a file called 
p1.script.  

Enter "cat p1.script".  This causes the computer to type the contents of the 
script file p1.script that you made.  Doing this is like "playing back" a 
"tape" of your interaction with the computer.  Now enter "jove p1.script" so 
you can look at the script file with the jove editor. You see your script.  
You also see "weird" characters in it. For example, you see one or more of 
these: ... ^M ... at the end of many lines.  These characters are an 
undesirable side-effect of the way the scripting program interacts with 
special characters that handle the terminal display.  The weird characters are 
sometimes visible, and sometimes not, depending on just how you try to display 
your script file.  Do C-x, C-c to exit jove.

When you turn in a real programming assignment, you will be sending me the 
source code, plus a script similar to the one you just made.  The script will 
be a record that will show me that you did the right kind of testing of your 
program.

Before sending me a script, you must filter out the worst of the weird 
characters, so the script will be more readable. Here's an easy way to do 
that:  Enter "cat p1.script | col -b > temp". This command pipes the script 
file to the input of the command "col -b > temp", which filters out some of 
the weird characters and writes the output to a file named temp.  Now the temp 
file is the filtered version of the script.  Enter "mv temp p1.script" to 
replace the script file with the new filtered version.  Now enter "jove 
p1.script" again.  See how the file has been cleaned up?  Good.  Exit jove 
again by doing C-x, C-c.

12. When you have the shell prompt back, enter

mail -v -s "p1 source" john@ishi < p1.cpp  

DO Include the quotes above!  This command sends me an electronic mail (e-
mail) message.  The title of the message is "p1 source", and the message 
itself is the program you just created, contained in the file called "p1.cpp".  
The program that I use to read my electronic mail shows me a list of one-line 
descriptions of the messages that have arrived for me.  The title of each 
message is part of this one-line description. Since I receive a large amount 
of e-mail, it is very important to me that you give your message a title.  
Without accurate titles, I cannot sort the mail efficiently.

As the course progresses, you will send me many e-mail messages.  Usually they 
will be files that you have prepared previously.  For example, a file you send 
may contain a C++ program, a script of the tests you made of a program, or a 
question about an assignment.  You can send any of these things to me using 
the form of the command above.  Always put the name of the file you are 
sending last, and place a title for your message between quotes after the -s.  
The title of the message may consist of several words, as long as you don't 
forget to put the quotation marks before and after the title.  

Since you include the flag -v in the command above, the mail program uses 
something called verbose mode.  It prints important parts of a dialogue that 
takes place between two programs as the mail is sent.  If you see on the 
screen a confirmation message like "john@ishi...Sent", or "Mail accepted" and 
"ishi.csustan.edu delivering mail" then you can be sure that the mail you sent 
got through to my electronic mailbox.  If you see some error message, 
something may have gone wrong, and you may need to try to send the program 
again.

(To get another prompt from the shell, you may need to press the Enter key 
now.)

Now enter

mail -s "p1 test script" john@ishi < p1.script

This sends me the script file you made.  This time you left out the -v, so 
mail "does its work silently."

Congratulations!  You have just completed all the steps of a sample 
programming assignment.  

13. If you haven't already done so, think of a good password now and change 
your password.  See step 6 for the directions. A secure password is important 
to you.  Attempted break-ins are common.  If someone gets access to your 
account and trashes your work, you have a problem!

14. If you are telnetting, make a safe exit from the system by typing 
"logout".  If you are at a console, then click the right mouse button in the 
background, select "Logout", and click on "OK".

15. You do good work!  Go get a cup of coffee, or a glass of your favorite 
beverage, and kick back.