- Getting an Account:
If you don't already have an account on the
CS Dept Sun Ultra network, then get a user name and password from your
- Finding a Machine: Locate an available Sun Ultra
personal computer you can telnet from. Your instructor and/or a lab
can help you.
- Starting to Login: Some names of the lab Sun Ultra's
altair, arcturus, barnard, capella, castor, centauri, ceti, deneb,
polaris, pollux, regulus, rigel, saiph, sirius, sol, soleil, spica,
zaurak. If you are telnetting in from a computer that is not a Sun
make a random choice and log in to one of the machines named above. If
need help logging in, raise your hand or consult the appropriate
the handout entitled Gaining Access to Workstations in the Computer
Department Network. (This document is available in the class web
under the file name
- Entering Username and Password: To login, you enter
name and password when prompted. The password you type will not show on
screen. This is normal. It is a security feature that helps prevent
from observing your password.
- Declaring a Terminal Type and Waiting for Login to
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 probably be your user name, followed by an "@"
then the name of the host you are logged into, then a colon, and then a
more characters. For example, if your user name were "jdoe"
were logged into zaurak, your shell prompt would be something like:
"jdoe@zaurak:(~)". This prompt means that the Unix shell
ready to accept a command.
If you just sit down in front of one of the Sun Ultra's and try to
login to it
(it's called "logging in at a console"), you may see a panel asking
which graphical user interface (GUI) you want to use. If so, be sure
that Common Desktop Environment (CDE) is selected. Then wait
graphic "desktop" appears. Next near the bottom of the screen, move the
arrow into the small square that is just to the left of the square
the question mark (?). Then move to the little triangle at the top of
square and click on it. A menu titled "Hosts" should pop up. If that
happen, raise your hand to get some help. Once you have the menu, click
"Console." The menu will retract, and a new window will appear with a
prompt as described above.
- Changing Your Password:
Optional step: At this time, you can change your password. You just
somewhere in the middle of the window containing the shell prompt and
enter "nispasswd" After that, follow the directions on the
Before you enter the command, you must first think of a good password.
advice on choosing a password.
- Starting the Editor and Entering Text: Enter "jove
This starts up a text editor called JOVE, working with a file buffer
JOVE is a lot like some PC applications you may be familiar with:
TextEdit, or SimpleText.
Unless the file already exists, the screen goes blank, except for some
documentation lines at the bottom. JOVE is running. Type the following
It is a very simple C++ source program. If there is already text on the
screen, erase it and type the text below.
using namespace std;
int main (void)
cout << "Hello World!" << endl ;
return 0 ;
- Saving and Exiting: Now figure out how to use the
keyboard to do this JOVE command:
What I mean by the command above is "while holding down the ctrl-key
hand, with the other hand press the x-key, release the x-key, press the
and release the \-key. Finally release the ctrl-key."
JOVE -- a quick reference guide
for more information about JOVE commands:
If you haven't done it already go ahead now and do a C-x C-\
command in the window where JOVE is running.
The C-x C-\ command causes a copy of the program you typed to
saved. It is saved as a file named p1.cpp, because of the name you
C++ programs for the g++ compiler on the Suns are supposed to
names ending in ".cpp" or ".cc". In other words, they should have names
p1.cpp, myprog.cc, prog3.cpp, and so on. This is very important. If the
".cc" or ".cpp" is missing, the compiler or linker may fail, even
program has no errors.
Now do this JOVE command:
(You have to use again the definition of C- you just learned.) The
causes JOVE to terminate. You should now be seeing your shell prompt
- Compiling and Linking: Next enter "g++ p1.cpp".
the command that compiles (and links) your program. It tells the
(g++) to translate p1.cpp into a machine-language version of
- Checking for Errors and
Executing the Program: If you got an error message, it probably
that you made a mistake when you typed the program. In that case, fix
back to step #7. If there were no errors in your program, then your
compilation succeeded, and the name of the executable translation of
program is "a.out". In that case, enter "a.out", to
the program. You should see the message "Hello World!" that
program prints on the screen. Did you see it? If so, give yourself a
the back. You just wrote a C++ program, and it does what it's supposed
- Making a Record of a Program Run: Now that you are
sure the program is working correctly, let's
test. This one will be "for the record." Enter "script p1.script"
and wait until the computer writes a prompt on the screen again. (There
be a slight delay. The prompt you get now may be different than
Here's an explanation of what you just did: The "script"
turns on a program that makes a record of whatever appears on the
command you entered was "script p1.script" so the record the
program makes will be a file called p1.script.
Enter "a.out" and see your "Hello World!" message
the screen again. Now enter "exit" to turn off the scripting
program. From the time you entered "script p1.script" to the
you entered "exit", all things that were written on the screen
also recorded in the file called p1.script.
Enter clear to clear the screen. Now enter "cat p1.script".
This causes the computer to type the contents of the script file you
It should look something like this:
Script started on Sat Aug 21 19:05:11 2004
script done on Sat Aug 21 19:17:37 2004
Note that the script file (named p1.script) starts and ends with
that tell when the script was started, and when it was completed. In
it reproduces what you typed.
Now enter "jove p1.script" so you can look at the file with
editor. You see your script. You also see "weird" characters in the
like ^M at the end of each line, and maybe some other things. These
characters are an undesirable side-effect of the way the scripting
interacts with special characters that handle the terminal display. The
characters are sometimes visible, and sometimes not, depending on just
try to display your script file. The characters were not visible when
displayed p1.script with "cat," but they were visible when you
JOVE. Do a C-x C-c command 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
be a record that will show me that you did the right kind of testing of
I require you to run your script through a filter before you send it to
It's a way to get rid of most of the weird characters, so the script
more readable. It is easy to do, no matter how big the script is.
Here's how: Enter "cat p1.script | col -b
temp". This command pipes the script file to the input
command "col -b > temp", which filters out some of the
characters and writes the output to a file named temp. Now the temp
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
file has been cleaned up? Good. Exit JOVE again by doing a C-x C-c
- E-Mailing Program and Script: When you have the shell
mail -v -s "p1 source" email@example.com < p1.cpp
DO include the quotes above! This command sends me an electronic mail
mail) message. (To get another prompt from the shell, you may need to
press the Enter key
Because you typed
-s "p1 source"
in the command above where you did, the subject line of the e-mail
that comes to me will be "p1 source". Because you typed
where you did in the command, the message I will receive will be your
called p1.cpp, which is your program.
Since I receive large volumes of e-mail it is very important
put the right subject line on every e-mail you send to me.
As the course progresses, you will send me many e-mail messages.
will be files that you have prepared previously. For example, a file
may contain a C++ program, a script of the tests you made of a program,
question about an assignment. You can send any of these things to me
a command that has the same basic form as this command:
mail -v -s "p1 source" firstname.lastname@example.org < p1.cpp
Of course, you have to use different versions of the command, depending
what subject line you want and what file you want to send to me.
It is OK if the subject line is a series of several words like
"Come quickly, the printer is jammed!"
but the series of words must be quoted like the example above. Also,
(-s) has to come just before the quoted subject.
You don't have to include the flag (-v) in the command. If you
include it, put it where shown -- before the (-s).
include the (-v) the program that transmits the mail responds
using something called 'verbose mode'. The mail-transmission program
important parts of a kind of dialogue that takes place between the
receiving programs as the mail is sent. If, near the end of that
you see on the screen a confirmation message like
"email@example.com... Sent (i7M2dO7s007156 Message accepted
then probably the mail you sent got through to my electronic mailbox.
see an error message, you probably need to try to send the program
you are careful and type the mail-sending command correctly, there is
little that can go wrong. Even if the destination computer is down, the
sending computer will keep trying to send the e-mail ... for several
How can you be sure that I get the e-mail you send? Usually it is
do two things: First use the -v flag and verify that the output looks
'normal'. Second, wait a minute or so and then read your unix mail by
and look to see if there is a line at the bottom of the display with
saying "Returned mail," and with timestamp close to 'now.'
If you see that, then enter the message number. For example if you see
>R 42 Mail Delivery Subs Sat Aug 21 20:49 71/2368 Returned mail: see transcript for details
at the bottom of your screen, enter 42 and read the message. It will be
message from the mail-sending program telling you it could not send
e-mail and trying to explain why. Read through the information. Press
space bar, if necessary, to get to the end of the message. Try to
what the error message means.
When you get the
prompt from the mail-reading program again you can enter an x to quit.
sending the mail again ... this time correctly.
mail -s "p1 test script" firstname.lastname@example.org < p1.script
This sends me the script file you made. This time you left out the -v,
mail "does its work silently."
Congratulations! You have just completed all the steps of a sample
- Change Your Password: If you haven't already done so,
think of a
good password now and change your password. See step 6 for the
secure password is very important to you. Attempted break-in's are
If someone gets access to your account and trashes the class work in
files then you have a problem! Also, someone could get control of your
account, masquerade as you, and do bad things.
- Exiting the System: If you are telnetting, make a safe
the system by entering "logout". If you are at a console, then
the right mouse button in the background, select "Logout", and click on
- The End: You do good work! Go get a cup of coffee, or a
your favorite beverage, and kick back.