#! /usr/bin/perl use strict; use CGI; my $cgi = new CGI; my $file = $ENV{DOCUMENT_URI}; $file =~ s|^/||; $| = 1; # turn off output buffering and print out content header print "Content-type: text/html\n\n"; # Set our variables from the CGI my %vars; $vars{background} = $cgi->param('background') || "#119511"; $vars{root} = $cgi->param('root') || $file =~ m|^(~[^/]+/?)|?"/$1":"/"; $vars{title} = $cgi->param('title') || "CTL"; $vars{separator} = $cgi->param('separator') || ' => '; #################################### #Create the title bar #Process the beginning of the header my $header = "\n" . $vars{title} . ''; #don't process the file's name my @components = split('/', $file); my $tail = pop @components; if ($tail =~ m|index\.s?html?|i) { $tail = pop @components; } #If this is in a home directory, we've already added that in. shift @components if $file =~ m|^~|; #build the inbetween stuff my $path; foreach my $foo (@components) { next if $foo !~ /\S/; $path .= "$foo/"; my $newfoo = ucfirst $foo; $newfoo =~ s|_| |go; $newfoo =~ s|\.s?html?$||gio; $header .= "$vars{separator} $newfoo "; } #Add on the name of the file if ($tail ne '') { $tail =~ s|\.s?html?||io; $tail =~ s|_| |go; $tail = ucfirst $tail; $header .= "$vars{separator} $tail "; } #################### #Get the URLs right $header =~ s|//|/|go; $header =~ s|tp:/(?!/)|tp://|gio; $header .= "\n"; #and finally print the thing. print $header;

Linux, the Universe, and Everything

A small guide to programming and nearly everything else on Linux

Hi. I've heard many people say that they want to program, but don't know how. There are thousands of books and tutorials on how to program, but most of them are either way too skimpy or too comprehensive to start out with. So I am writing this document. My goal is to provide an introduction to C and C++ programing in a linux environment. As such, I'm also going to cover some interesting tricks, some shell programming, and some info on how a Linux/Unix system behaves. I hope that this proves useful to you. If nothing else, remember the Hitchhiker's Guide to the Galaxy mantra: Don't Panic. Learning to program will take time and patience, but it will be rewarding. Learning how to control your enviroment is always like that.

Because much of this guide is designed to acquaint you with a linux environment, substantial sections of this guide should be applicable even to those who have no interest in programming. If you have the time, please let me know what you think of this guide, how useful it has been to you, or any suggestions that you have for its improvement (lansdoct@alfred.edu).

Contents

  1. Typographical Conventions
  2. Getting Started
    1. The Boot Process
    2. Linux/Unix Terminology
  3. The Command Shell
    1. Some useful command-line programs
  4. The X Window System
  5. Regular Expressions
  6. Networking
    1. Protocols
    2. Specific Protocols
  7. Compiling
  8. Makefiles and Autoconf
  9. Recovering From a Crash

lansdoct@cs.alfred.edu