Navigation table for Harper Computer Science lab courses rules and guidelines.
Behavior Working in Windoze
Logging into Unix Editting a Program
Terminal Terseness Compiling a Program
Running a Program 'Printing' a File
Handing in a Program Logging out of Unix

General Lab Rules Still Apply

Just because you are in a 'closed' lab facility does not mean you can eat and drink and play games. Please respect the facilities, each other, and yourselves.

Windows

Unknown Applications

If you arrive at a workstation and find applications you either don't know or didn't start, it's best to close them down before you start doing your own work. To kill most Windoze applications, you can simply hit Alt-F4 (that is: the alternate key in conjunction with the 4th function key) and answer affirmatively to any requests to confirm the app's death.

(If you are particularly paranoid, you may even want to reboot the machine. Personally, I shut the machine down, wait a couple of minutes, and then power it back on...except that I leave it connected to the network, I suppose that qualifies as fairly 'paranoid', too, doesn't it? *chuckle*)

Switching Between Unix and Windoze Programs

The Alt-Tab key combination will switch between any open programs. The Start key (aka the Windoze key) will bring up the Start menu so you can open new programs.

Logging Into Unix

Login Name and Password

Whether you plan to run nedit (to edit a program) or gnome-terminal (to compile, debug/test, or script your program), you are going to be connecting to the same account on the same machine: mars.harpercollege.edu. You'll need to know both your login id (or login name) and your password. When your account is first created (by IT when you register), they use your Student Portal login id. But they do NOT use the same password. (That would be a security risk. You should always use different passwords for different accounts. Mix letters, digits, and punctuation. That sort of thing. But make it something you can remember, of course.)

The password is set based on your Harper Student ID. To find your ID number, login to your Student Portal account and click to the My Registration tab. Next look on the left side for View Student Schedule Summary and click that link. Your Harper ID will then be in the upper right corner in front of your name. When you type it into nedit or gnome-terminal, make sure that the H in your Harper ID number is lower case.

Note here that unix is case sensitive! (In general, you should use all lower case unless instructed to capitalize.) Once you're logged in, it's a whole new world! *smile*

Also note that as you type in your password, nothing will appear on the screen. This is meant as a security mechanism so no one can look over your shoulder and tell how many characters long your password is to limit their search.

Finally, make sure that NumLock is on if you are trying to use the keypad to enter digits.

Once you've entered your login id and password, the black window will disappear and a second or two later, another will take its place — either a nedit window or a gnome-terminal window depending on how you first tried to log in. If no second window appears, the password or user name must have been entered incorrectly. Please try again.

Changing Your Password

Noting that your Harper ID, while difficult to come by online, is also on your actual student ID card (minus an H and 0 or two), you may desire for a more secure password. All connections to mars are made by a protocol known as ssh or Secure SHell. This makes all transactions encrypted and safe. But still, a better password is ideal. So, how do we change your mars password?

We'll use the passwd command in the gnome-terminal interface. Just type this command — passwd — into the gnome-terminal window and you will be prompted for your current password (to confirm you are you and not someone who just walked up to a window left open in the lab by accident). After that, you will be asked to type in your new password — twice. Keep in mind the information about security mentioned above. Also notice that the mars password manager won't let you pick things that are like 'dictionary terms'. It has a large dictionary...

Editting

Editting of programs can be done in one of two ways: kinda graphical and soooo not graphical.

Semi-Graphical

The simplest is to login using the nedit program. This is a semi-graphical editor (like Notepad in Windoze) for our Linux machine. It will let you edit your programs' source codes and save any changes you make on your unix account for later compiling, testing, and/or execution.

Setup and Configuration

Although many things about nedit are self-evident, here are a few tidbits that escape many people's attention:

In the Preferences menu, please note that anything from preferences, it is not automatically saved! To have something saved so it will be the same next time, select it from Default Settings instead of the main Preferences menu AND THEN choose Save Defaults from the main Preferences menu.

Some of the things you can set up here to make your life easier are:

Not-Even-Graphical

The more difficult way is to use either vi (although it is actually vim; and, truthfully, it has a graphical-y version called gvim which will pop out of the terminal when you run it) or nano (this is a clone of the insidiously and peculiarly popular pico editor which came with the mail system pine; more information can be found at their home page) in the gnome-terminal window. These editors are command-line, plain text editors. Both are available on many Unix machines/environments, but each has its own approach to editting a document and its own look-and-feel™. To get some help on nano, you can read its manual or information pages:

...$ man nano

or:

...$ info nano

(But you might want to read the man page for man or info — or similarly the info page for man or info — first. They each have their own approach to documenting programs and their own look-and-feel™. *grin*)

Another helpful resource can be found at the Academic Computing and Communications Center (ACCC) of UIC. (It is actually help for pico. But since nano is a clone of pico, the information should still be fairly helpful.) (The staff of UIC's fine ACCC is doing stellar work here! They seem to have done a fine job on these brief tutorials. I salute you, sirs and/or madams!)

You can also, as mentioned, use vi (or its newer cousins vim or gvim). This is one of the two most popular command-line, plain text editors available for *nix/Windoze platforms. (Its nemesis is the insidious emacs. *hiss* *boo* *hiss*) For help using vi, you may ask your teacher for one of our basics handouts, see your Unix book (the 'recommended' one), or even see its man or info pages (as above, but substitute vi for nano). (Note, also, that there is a link at the bottom of UIC's ACCC's pico tutorial page to some vi help.)

Configuration Got You Down?

Finally, you can feel free to borrow my personal configuration files if you are having trouble with menus and/or commands:

Extension Choice When Saving

Where ever you decide to edit your program, remember to save with the proper extension based on the language you are programming in:

Language Source Code Extension
C++ .C (capital)
or
.cpp (lowercase)
C .c (lowercase)
FORTRAN .f (lowercase)
Java .java (lowercase)

Most unix programs won't recognize your program as the desired language if you don't use an extension from this table! (And remember that ProPEr cAsE is important!!!)

General Terminal Usage

Also remember that when working in the terminal window, commands to run applications can be typed after the $ prompt — which is unix's way of saying, "Hi, I'm waiting for you to tell me what to do now..." When a command/program is done, they will typically give no particular answer unless something went badly. Either way, unix will respond with another $ prompt for you to tell it the next thing to do.

Compiling Programs

First choose the compiling means from the table below — based on the language you are using in your course:

Language Compiler/Script to Translate
C++CPP
CC
FORTRAN g77
or
f77
Javajavac

Then, to compile your, say C++ program, at a $ prompt type (just the part in this color):

    $ CPP progname

Fill in progname with your program's name. (Note that the .C — or .cpp — extension is optional for compiling a C++ language program as is the .c for compiling a program written in C. These 'compilers' will only work with files having the proper extensions.)

Caveats to Compilation

Both g77 and f77 for FORTRAN require you to type the .f extension.

Also, javac for Java requires that you type the .java extension.

Running Programs

At a $ prompt type (again, just the part in this color:

    $ ./progname.out

Be sure to substitute your program's name for progname. Also, note that you use an extension of .out instead of your language's usual extension — .C/.cpp or .c or .f! (.out is a standard unix executable extension, similar to .com or .exe in DOS/Windoze.) And note the ./ in front! That is a standard unix security measure to help avoid the effects of break-ins! You are essentially telling the computer to execute the file progname.out that resides in the current directory (i.e. folder). The . represents the current directory (succinct, isn't it?). The / means 'the right item which is within the left item' — so here we have the executable name on the right and the 'current directory' on the left.

Caveats on Execution

If you are using FORTRAN, your executable name will always be a.out no matter what your program's .f file was called.

If you are using Java, your 'executable' is named correctly (albeit with a .class extension instead of .out), but you must run it via the Java virtual machine (JVM) like so:

    $ java progname

Notice that you do not type the .class to run your Java program!

'Printing' Files

To print a file, first we need to prepare it. In these ergonomic...er...economic...um...ecological...*bah* Well, these days we've gotta save trees! So to print a document, we'll first perform a '2-up' transformation on it (making two pages appear side-by-side in landscape on a single sheet). To turn our plain text files into a fancy 2-up printout, we need to use a utility to transform them into a printer language known as PostScript.

There are several options installed on our unix machine to perform this transformation: mpage, a2ps, and enscript. To use any of them, you could look through its respective manual page or information listing or even try running it with a --help command line option (sometimes -h or even -?). But, to save you that bit of effort, here are the basic commands you'd want for enscript:

OptionMeaning
-2 print 2 pages per sheet
--landscape
-r
print in landscape
-j print a border around each page's column on the sheet
--media=Letter use 8.5"x11" (letter size) paper
(most administrators don't bother to change the default from A4 size paper — a European standard size)
--pretty-print=langcode
-Elangcode
make some programming language syntax prettier by using bold and italics to high-light parts of the code
codes for languages are cpp for C++, c for C, and fortran for FORTRAN (oddly enough...)
-ofilename.ps the name of the file to store the PostScript codes into
typically this will be the file you are printing but with a .ps extension [added]

So to translate a file you have named... oh, let's say 'typescript' ...into a PostScript version for 'printing', you could use the following (at your $ prompt):

    $ enscript -2jr -Ecpp -oLast-First-progname.ps typescript
    [ ?? pages * 1 copy ] left in Last-First-progname.ps
    2 non-printable characters

Here we've specified that there are indeed to be 2 pages per sheet oriented in landscape (r) with a border (j) around each page (note also how these three all share a common -). The result is stored in Last-First-progname.ps due to the -o option. (That's your last name, a dash, your first name, another dash, and the name of your program — less the .cpp extension.) And, finally, any C++ syntax will be high-lighted prettily (-E).

The result is normally the above line (or something remarkably like it). The ?? will be filled in with the correct number of pages for your particular printout, of course. If you get a warning like this:

    !! lines were wrapped

Then you'll want to fix those lines which were too long, now won't you! (It is part of good style, typically, to keep your lines from wrapping both in the source code and in the program's user interface. Of course, languages like FORTRAN are more forceful than most...)

If you see a line like this, however:

    ?! non-printable characters

Don't worry so much about it. You probably just hit a weird key during your scripting or something. (If you are working from home, perhaps your CygWin or Linux ...or even BSD... system has some sort of weird display parameters in the default prompt. Ask your instructor about how to fix it or email craie@acm.org. Either way, be sure to mention/include [at least general] details about what your prompt looks like and give them/attach a copy of your shell configuration files.)

Next, you'll want to turn this PostScript file into a PDF. The command to do this is ps2pdf. It just needs to know what file to transform from PostScript into PDF.

To test this out, you can go to a $ prompt and type:

    $ ps2pdf filename.ps

Here filename is typically Last-First-progname. The reasons for this were made clear above...

(The careful reader will notice that we never actually printed anything throughout the 'printing' section. That is because trees are people, too! Have a heart! Don't pollute! *smile* *grin*)

Scripting your Programs for Handing-In

In the instructions below, remember that you type the part in this color. Fill in the progname part with the name of your file. Repeat the execution (progname.out) as often as needed to thoroughly test your program. Do NOT forget to exit before PDF'ing (with enscript and ps2pdf).

(If you do not have a particular file that is cat'ed during the script, don't worry — just skip that line and move on. Your instructor will let you know if that file was truly necessary for your course/section.)

(And if your program fails to compile, that's okay, too. By scripting and simply skipping the execution portion, your instructor will have more information to help you locate the error(s).)

$ script
Script started...
$ pwd
/home/students/...
$ cat progname.info  # this only works if you have created an information file 
 .
 .
 .
$ cat progname.cpp
 .
 .
 .
$ CPP progname
progname.cpp***


$ ./progname.out  # run 3-5 tests of your program to show a good sample of your debugging efforts
 .
 .
 .
$ cat progname.tpq   # this only works if you have created a Thought-Provoking Questions file
 .
 .
 .
$ exit
Script done...
$ enscript -2jr -oLast-First-progname.ps typescript
[ ?? pages * 1 copy ] left in Last-First-progname.ps
2 non-printable characters
$ ps2pdf Last-First-progname.ps
$ _

(And remember that the ?? after enscript will be filled in with the correct number of pages for your particular 'printout'.)

(Finally, if your script 'printout' includes lines of seeming garbledygook, don't worry about that, either. It means you used the Backspace key or the arrow keys during the script. If we cared that much, we'd/get the system administrators to write something to remove that. *shakes head* It's okay. Teachers live with far worse every day. Don't worry 'bout it... Sa'right...)

Now that you have a PDF version of your script session, you can download it to the PC and attach it to an email (you have some kind of web email, right?) to me (craie@acm.org). Make sure the subject contains your name, course, and section. (It would also be convenient if the subject contained an indication as to whether you wanted corrections or this is your final — aka portfolio — version for a grade.)

Logging Out

Application How to Close Out
gnome-terminal Type exit and Enter or Ctrl-D (the Control key in conjunction with the D key) to exit the terminal.
nedit Make sure you've saved (choose File|Save or File|Save As from the menu), then either choose File|Exit or hit Ctrl-X or even click the [X] button in the upper right of the window's title bar.

Always remember to log out completely before leaving the lab. If you leave your unix connection windows open, others can access/use your account as if they were you. They might steal, destroy, or even harass in your name!

If you are in our lab (D104), it would be nice if you could do a Log Off before you leave (not 'Shutdown' although 'Restart' would be okay, too).