Note: All assignments are required. The trailing R in a conference title means the conference is required. The trailing O means that the conference is optional.
Okay, you are finally ready to start taking some adult steps as UNIX users and programmers. This week you will be introduced to the Shell. It is responsible for:
In the typical /etc/passwd file you might see an entry like this as an entry for me:
cdekle:*:15:47::/users/cdekle:/usr/bin/bash
Therefore, every time that I login to this system I will see the bash shell prompt which in this case is the dollar sign as a default. I can create any prompt that I want but for now we will just stick with the basics. At this point I can begin running programs and doing real work. The shell waits for me to enter a command which it then parses and executes. If the command is incorrect, it returns an appropriate error message. If the command is correct, the shell executes it and then returns to the prompt waiting for the next command until I log out.
This seems simple but its power is in its simplicity as you have been finding out from your reading assignments and your own environments. Let me add a word of caution at this point. Don't be fooled by the ease with which you can do things at the system level. UNIX assumes that you are an expert user so it does not do a lot to protect you from yourself if you have super user status or root. Just be careful and plan your actions before executing. When you delete something it is gone for good.
Chapter 7 covers the basics and introduces a lot of complex topics. Don't worry the later chapters will cover these more fully. For instance one of my favorite tools is the pipe. You can do a lot of complex things using pipes to operate on text files with some of the old standard UNIX utilities.
There is also a brief introduction to shell variables and shell scripts. After the break we will learn to use the shell interpreted programming language along with perl but with just the basic shell commands, pipes, sed, grep, regular expressions, and awk you can do some pretty expert processing without too much trouble. Remember the Lego example--big constructions using small blocks.
The shell commands are analogous to the DOS commands that some of you have mentioned. The Window/DOS batch files are also related to shell scripts. The difference being that shell scripts do not need a particular extension whereas DOS batch files must have the .bat file extension.
I don't mean to cast aspersions on batch files I actually used one to run a check writing program when I worked for a collection agency in Key West. If you beg me I will tell the story of why my karma is so black that I must work for the IG for the rest of my life to make amends. That statement alone should tweak your curiosity. If you tell me some stories of your own in this week's Cybercafe, I will share mine with you. This will also assure me that you are actually reading the class content each week.
I don't think that I have given you this link yet but it is good for more than just UNIX. Click around in some of these:
If you have not caught up with your reading assignments from the textbook, I suggest that you do so soon. Beginning with Chapter 4 and for the rest of the term you will need to read and practice the commands and scripts. The midterm anticipates that you have done your "do diligence" as auditors say even though it is open book open notes. You will need to be prepared.
If you are using Cygwin one of the things that you will have to do is to make sure that your home directory is in the $PATH environment variable. Each time you launch Cygwin it calls up an old fashioned DOS batch file named cygwin.bat. Mine looks something like this:
@echo off
C:
chdir C:\cygwin\bin
bash --login -i
It issues some basic DOS commands and moves the actions a directory called C:\cygwin\bin. It then starts the bash shell emulator which brings up my terminal window. One of the first things that bash does is look for one of my default profile files. I have one in my home directory C:\cygwin\home\cdekle called .bash_profile. It is a standard file name and bash will read it and set my preferences for the session.
The only thing that I have there so far is how I want my $PATH shell variable set so I added this line:
PATH=$PATH:/home/cdekle
Please note that there is a blank line at the end of the file to conform to the UNIX format. Now if I have a shell script in this directory, I can execute it like so:
cdekle@CharlesII ~
$script.sh
The date today is Sun Feb 12 19:47:21 EST 2006
The current directory is /home/cdekle
cdekle@CharlesII ~
$
This is the example from page 209 of this week's reading from the textbook. What you see is that cdekle (me) is logged on CharlesII (one of the computers on my home network and that I executed the script. If I had not changed my $PATH environment variable I could have executed it as ./script.sh from the prompt.
If you have trouble with Cygwin not behaving exactly as a real bash shell just remember that it actually is a Windows NT program. It is very good basic teaching tool but there are some short comings related to running on Windows. Just post your questions in the class and maybe we can find some answers. I will always make sure that your assignments take those limitations into account if this is your only UNIX window.
Read Chapter 7 of the textbook and Module 2: The UNIX Shell found in Course Modules under Class Content.
Read Chapter 3, Contrasts: Comparing the Unix Philosophy with Others, at http://www.faqs.org/docs/artu/ . This is the book, The Art of UNIX Programming by Eric S. Raymond ISBN 0-13-142901-1. As always, add it to your discussions for the week if you wish.
Okay, you have had three weeks to start forming real opinions about UNIX. Do some research and speculate about the future of the operating system. Don't just offer an opinion. Back it up with some facts
Go to Conference C4.1R - Philosophy and post your comments under my topic. You should read and respond to several of the other comments that interest you. As always, I will be lurking about and will jump in from time-to-time with my own observations. You didn't know that this was a philosophy class, did you?
All of the materials presented and discussed in the conferences are fair game for the midterm and the final. If there are other related items that are not part of the normal curriculum then we can discuss them in the cafe.
The Cybercafe conference is an open forum for the free exchange of ideas. You may use it anytime. Use this conference to make appointments for other members of the class to meet you in the cafe.