CS248 Menu Buttons

UNIX Programming

"Introduction To UNIX Programming"

Lecture Notes

Introduction To UNIX Programming

UNIX was originally written by professional programmers for the use of other professional programmers. UNIX itself is written in C. Many UNIX systems also offer the FORTRAN, Pascal, and other languages.

Programming Languages

A computer program is a set of coded instructions that tell the computer how to perform some task. Computers understand machine language, which is stored in their memory as binary numbers -- combinations of 0s and 1s. Here is how a segment of a program might appear in binary form:

Obviously, it is tedious to program in binary code. A better alternative is to program in assembly language, which represents each machine's binary instructions symbolically. For example: This is still difficult to understand. Fortunately, high-level programming languages are available that make programming much easier. Here is that same program segment in the C programming language:

Programming in C

Here is a simple demonstration of making and executing a C program. First you need to start and log on to a UNIX/Linux system. Mandrake 8.1 release of Linux will work fine for this task!

1. Get to the command line (or a terminal window if you are in X-Windows.) To start a terminal window, Click on the K on the lower-left if the task bar, then on terminals in the pop-up window, then A Term or X Term.
2. Start the vi editor for a new filed called hello.c by typing:

3. Press the i key, to start the insertion mode.
4. Enter the following C program statements: 5. Now press the Esc key to stop the insertion mode.
6. Type the following: and then press the Enter key, to save the file and quit the vi editor.
7. To compile the pile, type: and press the Enter key.
8. To execute the program, type: and press the Enter key.
9. You should see the following output:

Programming in C++

Here is a simple demonstration of making and executing a C++ program. First you need to start and log on to a UNIX/Linux system. Mandrake 8.1 release of Linux will work fine for this task!

1. Get to the command line (or a terminal window if you are in X-Windows.) To start a terminal window, Click on the K on the lower-left if the task bar, then on terminals in the pop-up window, then A Term or X Term.
2. Start the vi editor for a new filed called hello.cpp by typing:

3. Press the i key, to start the insertion mode.
4. Enter the following C++ program statements: 5. Now press the Esc key to stop the insertion mode.
6. Type the following: and then press the Enter key, to save the file and quit the vi editor.
7. To compile the pile, type: and press the Enter key.
8. To execute the program, type: and press the Enter key.
9. You should see the following output:

.

Programming in FORTRAN

Here is a simple demonstration of making and executing a FORTRAN program. First you need to start and log on to a UNIX/Linux system. Mandrake 8.1 release of Linux will work fine for this task!

1. Get to the command line (or a terminal window if you are in X-Windows.) To start a terminal window, Click on the K on the lower-left if the task bar, then on terminals in the pop-up window, then A Term or X Term.
2. Start the vi editor for a new filed called hello.f by typing:

3. Press the i key, to start the insertion mode.
4. Enter the following FORTRAN program statements. Be careful, FORTRAN is fixed format. The * for a comment must be in column 1. The P of the statement PROGRAM HELLO, must start in column 7! 5. Now press the Esc key to stop the insertion mode.
6. Type the following: and then press the Enter key, to save the file and quit the vi editor.
7. To compile the pile, type: and press the Enter key.
8. To execute the program, type: and press the Enter key.
9. You should see the following output:

Programming in HTML

HTML stands for Hyper-Text Mark-up Language. It is used for making Web pages for Internet. We will now make a simple HTML file that will be used in the next section when we write and view a Java applet.

First you need to start and log on to a UNIX/Linux system. Mandrake 8.1 release of Linux will work fine for this task!

1. Get to the command line (or a terminal window if you are in X-Windows.) To start a terminal window, Click on the K on the lower-left if the task bar, then on terminals in the pop-up window, then A Term or X Term.
2. Start the vi editor for a new filed called HelloApplet.html by typing:

3. Press the i key, to start the insertion mode.
4. Enter the following HTML program statements. 5. Now press the Esc key to stop the insertion mode.
6. Type the following: and then press the Enter key, to save the file and quit the vi editor.
7. This file will be used in the second part of the Java section.

Programming in Java

Programming in Pascal

.

Programming in Shell (sh, bash, etc).


CS 248 - UNIX Programming Web Site Menu
Information | Syllabus | Schedule | Online "Lectures" | Projects | Quizzes | Web Board



Copyright © 2001 by James L. Fuller, all rights reserved.