CS 1440 - Lab 1 - Dr. Tashakkori

The topics covered by this lab are:

1. Windows Essentials
2. Opening multiple windows (applications) at once on the display
3. Logging into the UNIX machine, cs, and changing user password
4. Some UNIX commands
5. E-mail on cs using pine; compose, send, receive, reply, ...
6. Learn about pico a UNIX-based text editor
7. Assignment

A homework assignment described at the end of the lab will help you familiarize with the pico text editors and pine mail software on Unix. The homework for this lab is due by midnight Tuesday, August 28.

What do you need to do to receive full credit for this lab ?
In this lab, you will be required to send two e-mail messages.  You will get a grade of 100 on your first lab homework if I receive your e-mails by class time next Wednesday.

1. Windows Essentials

To "double click" on something means to click (usually the left mouse button) twice rapidly in succession. In Windows, two single clicks don't make a double click -- you have to be reasonably fast.

 To "drag" an object means to move the mouse pointer over the object, click once with the left mouse button and hold the button down (don't release it), then while the button is still depressed move the mouse. The object is moved with the mouse. We'll see how to move a window by dragging it just a bit.

The title bar at the top of a window has special properties. The three buttons in the upper right corner are used as follows:

Figure (1) - An example of a window (Netscape browser screen)

Once a window is minimized, it will appear as a button in the taskbar at the bottom of the screen, See Figure (2), by clicking on a button the large screen will return to the window at its previous state and location.

Figure (2) - Taskbar of Windows

When a window is maximized, it occupies the full screen. A resizeable window occupies a portion of the screen and can be moved or resized with the mouse. To move, press the left mouse button on the colored portion of the title bar at the top of the window and "drag" the window. To resize, put the cursor on a border (it changes to a double-headed arrow), press the left mouse button and drag the border.

2. Opening Multiple Windows (Applications) at Once
For most of the labs in this course, you will use (at least) two windows at once: a Netscape window similar to the one shown on Figure (1) to see the description of the lab, and a terminal window similar to the the one shown on Figure (3), for writing and running programs and for other activities on our Unix system. You can switch between tasks by clicking the appropriate task button in the taskbar at the bottom of the screen, or by moving the mouse to any portion of the desired window and activating that window by clicking on it.

Figure (3) - Terminal window (the Telnet screen)

3. Logging to a UNIX machine 'cs':

This lab is very easy and is designed to teach the basic skills that you need for this course throughout the semester. The better you master these skills the easier future labs will get for you. This part is designed to introduce you to the environment you will use to write, compile, and run your C++ programs.

First, you will log onto the UNIX machine, cs. Once again, click on the Start button in the taskbar at the bottom of the screen, point to Run to open the Run screen.  This screen is shown on Figure (4).  At the field Open type:

telnet  cs.appstate.edu.
Note that if the machine that you are using is on the same network as cs (like those machines in the computer labs in our department) then you can get to it by simply typing:
telnet cs

Figure (4) - The Run screen (e.g., running Telnet to cs machine)

This will give you the screen on Figure (8).  If you wish to learn another way to Telnet continue, otherwise, move to Figure (8).

You could also run Telnet without any argument in front of it.  In that case, you will get the blank telnet screen shown on Figure (5).

Figure (5) - The blank Telnet Screen

Click on Connect tab.  To get a screen similar to the one shown on Figure (6).

Figure (6) - Telnet Screen with connection options

You have two options for connecting to the desired Unix machine.  If the name of the machine to which you are connecting appears in the list, simply click on it and you will be connected to that machine.  Please note that the cs machine may appear either as cs or cs.appstate.edu. The second option is to click on the Remote System tab to get the Connect screen shown on Figure (7).

Figure (7) - The Connect screen from Remote Connection tab

The Host Name is the name of the machine to which you want to connect (in our case, cs).  You can leave the other two fields as default.  By clicking on Connect button, your computer will try to establish a connection with the requested machine .  Once you are connected, you will get a screen similar to the one shown on Figure (8).

Figure (8) - The cs login screen

Type your login name (same as the one you have given on ASU's VMS system) on cs, press enter, then enter your password (same as the one you have on VMS) and press enter to open your account on the cs. Note: if you do not know your user name or password, I will try to get it for you.

After you type your initial password, you will be logged into the system and will be asked to change your password. Follow the directions on the screen to change your password. Important Note: To  improve security of your account, your password should consist letters, special characters such as !,@,#,..., and numbers.  A reasonable length for password could is 8 characters.  Be sure to remember the password that you selected. From now on, you will use this password to login to the system.  If you decide to change your password again, type passwd and follow the directions on the screen.

Once you are logged in to cs, you will get a screen similar to the one shown on Figure (3).
cs)~%    or     cs.cs.appstate.edu>

We refer to the above statements as the command prompt.  From the command prompt you will be communicating with the UNIX operating system by entering your UNIX commands. On some machines, the command prompt will appear with a "$" character at the end.

4. Some Unix Commands (I strongly recommend that you go through the UNIX short manual on your own.  That is given as a problem in your homework)

Here we briefly review some of the UNIX commands that you need today.  Type:

cs)~% ls
to see the list of all files in your directory ("ls" stands for "list"). UNIX, like C++, is case sensitive so be careful of the CAPS LOCK key. Most UNIX commands are in lower case.

A Quick Note:  Any time you want to learn about a command, simply type:
% man   name-of-the-command.  The manual page will give display all the information about that command.

You'll probably spend most of your online time this semester in an editor writing and modifying computer programs. There are several editors on cs. We will use pico.  Let's start by opening an empty file and start typing a text.  To get the pico screen, type:

%pico template.C
Now you have told UNIX to run the pico program to edit a file called "template.C". If you already owned a file with that name, that file would be loaded into the pico editor. Since you do not have a file called "template.C" already, an empty one will be displayed.

Some of the commands that you need are listed at the bottom of your screen.  Note that ^ stands for the Ctrl key on the keyboard.  Type the text between *** lines in the blank screen.


// Last Name, First Name, CS1440, Section:
// Date:
// File Name:
// Description:
// Inputs: none
// Outputs: two English Statements
int main( )
   cout << "Hello, I am here \n";
   cout << "Bye, I am leaving \n";
   return 0;
Now that you are done with the text, you need to save and exit the file.  Look at the bottom of the Pico screen to find the command for Save and Exit.  That is:
Ctrl  x   (hold the Ctrl key down, then press x).
You will be asked whether you want to save the file or not, then  to have it with the same name.  I guess the answer is clear.  Once you are back at the command prompt (%), type ls to make sure that the file is created.

Let's make a copy of this file and then list all our files again. Copying a file is done with the "cp" command. You type cp followed by the name of the file you want to copy, then the name by which you want to call the copy.  It is a good practice to keep a copy of your program all the time.  Sometimes, you may delete your program by mistake.  It happens often at the beginning.  If you have a copy, you simply can use it to proceed.  To make a copy of the above file, type:

% cp template.C lab0.C

% ls
What do you see? Now type:
% mv lab0.C lab1.C
The "mv" command stands for the word "move"; it renames a file. We just told UNIX to change the name of "lab0.C" to "lab1.C".

We also need to know how to delete a file. In UNIX, the "rm" command deletes files; rm stands for "remove". If we type:

% rm lab1.C
This will delete lab1.C file. Try it and then list your files again to see if it worked.

5. Electronic Mail

One of the wonders of computer communications is electronic mail, or "e-mail." If you haven't used e-mail before, you'll soon find yourself hooked. You can send your thoughts almost immediately and you can mail as easily to 10 people as one. The email you receive is saved (until you explicitly delete it) and can serve as a transcript of your life (or part of it). Also, if you have questions about the class, I can answer your questions by email.

 This lab is to teach you:

on a UNIX machine.  The e-mail package (software) that we use is called Pine.  At the command prompt, type:
If this is the first time you've ever used pine, it will ask you if you want to receive a copy of some documentation that comes with the program. Choose yes or no. Then use the arrow keys to select the I FOLDER INDEX menu entry and hit return. Pine automatically opens your INBOX which holds new messages and also old messages that you haven't deleted or moved to another box.

You should have one email message from me. If that is the only email message that you have, then that one should be highlighted and you can simply hit return to read my message. If you have multiple email messages, use the down arrow key to highlight the message from me and hit return. (If you don't have any mail, you're not on my distribution list -- tell me and I'll fix the problem.) While you're looking at my message, notice the bottom few lines of the screen contain information about available commands. Sometimes there are more commands available than can fit on the two lines. Enter

to get to some of these other commands and then enter
to export the message into a text file. When it prompts you for a file name, type
This makes a copy of the mail and saves it in a file called temp.txt. (I tend to use "temp" in my file names if I intend to delete them soon.) We'll come back to this new file later, but now read the mail message and follow its instructions to reply to me. After you've replied to me, type "m" to return to the main menu.

Next, you'll send a message to another student in the class. Look at this list of user ids and send an email to the student whose name follows yours on the list. Then from pine's main menu, choose "c" for "compose message".

In the "To:" field, enter the other person's login name and press Enter. Keep pressing Enter until you get to the "Subject:" field. Always give a brief subject description, since subjects help the recipient find old mail. Enter a subject and press Enter. Then type your message and press "Ctrl-x" (and then "y") to send the message. Try to put enough information in the message that the student you are sending mail to can identify you. Have the student to whom you sent mail show you what the message looks like once it is received. Then type "q" to leave pine.

Now, verify that the export command you issued earlier actually saved the mail message by listing your files (use the

command) and then display the file by entering:
cat temp.txt
You'll notice that this command assumes you have passed a speed reading course! This time enter,
more temp.txt
You'll notice that the 'more' program displays a screenful of text at a time. To advance the display by a single line, press Enter. To advance to the next screenful of text, use the space key. To go back up one screenful, type "b". To quit the 'more' program, type the letter "q".

Let's return to mail -- type "pine" again. It is a good idea to keep your INBOX relatively clean. That way new email messages are easier to spot. So what can we do with email we've read and want to keep? Well, we've already experimented with the Export command. However, pine offers another capability - mail folders. In reality, your INBOX is a mail folder. You can create and manage your own mail folders. Let's create a mail folder for this class. From pine's main menu select "L" for "Folder List". Enter "a" to add a folder to your list of current folders. Enter cs1440 when pine prompts you for a folder name. Use the arrow keys to highlight our new cs1440 folder. Use the Enter key to open the folder. Notice that there are no mail messages in this folder - yet. Return to your INBOX folder (by returning to the main menu, listing your folders again, and selecting INBOX). Now, use the arrow keys if necessary to highlight the email message from me. Use the "o" key to see other commands. Let's use the Save command. This is how you can save a message from your INBOX to another pine mail folder. At the prompt, enter our new folder cs1440. It is important to realize that there are now 2 copies of this message. One in the cs1440 folder and one still in the INBOX folder. However, notice that the INBOX message has been marked for deletion (a "D" is now visible in the third column). When pine exits, it will delete this copy and then there will be only one copy of the message (in the cs1440 folder).

We can delete messages from folders that we don't want by highlighting the message and pressing the letter "D".

By the way, my user name is rt. Throughout the semester, you can send e-mail to me for help on your programs.  When you're done, type "q" if you're still in pine, then logout to leave cs. At the UNIX prompt, type

% logout
and press Enter.

Homework - Due by Midnight, Tuesday, August 28

Problem (1)
Go through the manual given for Pine to learn how to use pine to check your e-mails on cs. Send me an e-mail with subject "Problem (1)" and in the e-mail tell me your complete name, and major.

Problem (2)
Go through all the steps of the UNIX Short manual.  if you successfully complete the manual, at the end you will generate a file called typescript.  E-mail me that file. The subject line should say "Problem (2)".

Problem (3)
Soon, I will e-mail you a file called info.txt.  Use pine to read my e-mail, then copy that file into your directory.  Use pico to edit the file and complete the information.  Then save the updated file as userid.txt (please use your user id).  Now you have to e-mail me that file. The subject line should say "Problem (3).   Once I received your mail file, I will e-mail you back a confirmation.  You may not receive the confirmation immediately.  Check to make sure you have my confirmation, otherwise, your mail may have failed to go through.