Jim Kents's Web Programming Mini Tutorial

Getting Started

Creating a program that runs on the web at UCSC on a CSE computer is relatively easy. The first step is to simply verify that you have an account, and to create a home page for yourself. To do this log in and issue the following commands:
Type in This: To Do This:
mkdir .html create a directory (folder)
chmod a+rx .html let other people use it
cd .html go to that directory
cp ~kent/.html/tutorial/generic.html index.html copy in home page
chmod a+r index.html let other people use it
This will create the .html directory, where your web pages will reside, and also create a home or index page, which will initially just be a copy of a simple generic page with a link to the CSE department home page. You should be able to see your page on the web at http://www.cse.ucsc.edu/~yourLogin/index.html (in this case you can leave out the index.html). You can (and should) personalize this file later, either with a text editor, or if you're lazy like me, with an HTML editor. (Depending on how your Unix account was set up, you may not have to do all the chmods.)

The next step is to make a program that runs on the Web. To do this issue the following commands:
Type in This: To Do This:
cd ~/.html go to your .html directory
mkdir cgi-bin create program directory
chmod a+rx cgi-bin let other people use it
cp ~kent/.html/cgi-bin/hello cgi-bin copy a program to directory
chmod a+rx cgi-bin/hello let other people use it
This creates the cgi-bin directory, where all of your web programs will reside, and copies in a little program that just prints Hello World. You can access this program on the web by pointing your browser to http://www.cse.ucsc.edu/~yourLogin/cgi-bin/hello

How It Works

The World Wide Web uses URLs (Uniform Resource Locators) to find web pages. The URL for my home page is http://www.cse.ucsc.edu/~kent/index.html. The "http://www.cse.ucsc.edu" part tells a web browser what computer (and what communications protocol) to get the page from. The "~kent/index.html" tells the web server software running on that computer where to find the file that contains the web page. In this case the web server does a little translation to change ~kent/index.html to ~kent/.html/index.html. (This lets you keep your files not in the .html directory private from web surfers.) The web server treats files in the cgi-bin directory as programs. It executes cgi-bin programs and treats the program output as a web page. Cgi-bin programs can be shell scripts (like the hello program above), Perl scripts or compiled executable programs. Our web server runs on a Sun Sparc named ftp.cse.ucsc.edu, so compiled programs must be in Sparc format.

Links to More Info

This tutorial has just given you a very small taste of web programming. Here are some links if you would like to learn more.