For background for this lesson and activity you should refer back to the first lab you did on using a command line interface. If you log in to wyrd, you can follow along with some of the commands in the lesson.
Unix online reference manuals are called manpages.
is the man page for the cal (calendar) command. (Note: The symbol <AD> is used like a hyphen to indicate continuation.)
The command used is "man cal"
[echang@wyrd csci599]$ man cal
Formatting page, please wait...date
CAL(1) UNIX Reference Manual CAL(1)
NAME
cal - displays a calendar
SYNOPSIS
cal [-mjy] [month [year]]
DESCRIPTION
Cal displays a simple calendar. If arguments are not specified, the cur<AD>
rent month is displayed. The options are as follows:
-m Display monday as the first day of the week.
-j Display julian dates (days one-based, numbered from January 1).
-y Display a calendar for the current year.
A single parameter specifies the year (1 - 9999) to be displayed; note
the year must be fully specified: ``cal 89'' will not display a calendar
for 1989. Two parameters denote the month (1 - 12) and year. If no pa<AD>
rameters are specified, the current month's calendar is displayed.
A year starts on Jan 1.
The Gregorian Reformation is assumed to have occurred in 1752 on the 3rd
of September. By this time, most countries had recognized the reforma<AD>
tion (although a few did not recognize it until the early 1900's.) Ten
days following that date were eliminated by the reformation, so the cal<AD>
endar for that month is a bit unusual.
HISTORY
A cal command appeared in Version 6 AT&T UNIX.
BSD Experimental nbsp; June 6, 1993 nbsp; nbsp; 1
It tells us that
Try the commands
The echo command simply echos on the screen whatever you type on the line after it. For example, if you type "echo man ftp" the words are shown on the screen instead of being treated as a command.
[echang@wyrd echang]$ echo man ftp man ftp [echang@wyrd echang]$
If you type the following command
[echang@wyrd man_pages]$ echo AN EXAMPLE OF COMMANDS
The message AN EXAMPLE OF COMMANDS will appear on a line by itself
Many symbols, such as angle brackets (> and <) and the semicolon (;), have special meaning to the shell. If you want to echo them in text, you must place the text in quotation marks. For example,
echo here > there
echo me; you
will not echo the lines here > there and me; you. (Instead the first command will create a file named "there" and store the text "here" in it; the second will echo "me" and then display a shell error message.)
To echo the entire lines, you must use
echo "here > there"
echo "me; you"
Now suppose we want to put a blank line after the line "AN EXAMPLE OF COMMANDS ". But once you press ENTER (also called a carriage return), the command is completed.
Special characters which are "invisible" or have special meaning such as carriage returns, tabs and quotation marks are commonly encoded in commands and programming languages by a combination of "normal" characters - in Unix, a backslash followed by another character. This is referred to as "escaping" the character. Some frequently used codes are
To use these character codes, you must use the -e option to tell the shell command interpreter to evaluate them as codes instead of as the ordinary characters. You also need to enclose the escaped codes in quotation marks.
echo -e "\n" creates extra blank lines between the first line, the date and the who report.
[echang@wyrd man_pages]$ echo AN EXAMPLE OF COMMANDS [echang@wyrd man_pages]$ echo -e "\n" [echang@wyrd man_pages]$ date [echang@wyrd man_pages]$ echo -e "\n" [echang@wyrd man_pages]$ who
Try the commands
Echoing blank lines and messages onto the screen may seem strange, but there is a way to automate the process so that you can repeat an entire series of commands by typing a single line.
To create a script of shell commands:
pico file_name at the shell prompt[echang@wyrd man_pages]$ pico script1
UW PICO(tm) 3.5 File: script1
[ New file ]
^G Get Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where is ^V Next Pg ^U UnCut Text^T To Spell
UW PICO(tm) 3.5 File: script1 Modified echo An example script file echo -e "\n" date echo -e "\n" who ^G Get Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text ^C Cur Pos ^X Exit ^J Justify ^W Where is ^V Next Pg ^U UnCut Text^T To Spell
bash file_name. [echang@wyrd ~]$ bash script1 An example script file Wed Apr 19 11:25:52 EDT 2006 acrum pts/0 Apr 17 09:17 (orchid.hood.edu) echang pts/1 Apr 18 14:47 (70-32-5-123.frdrmd.adelphia.net) [echang@wyrd ~]$
Notice that all of the commands are executed.

chmod command.chmod command.chmod 755 my_filename

These instructions will let you call a script through a web server so its output can be seen in the browser.
#!/bin/sh echo -e "Content-type: text/plain\n\n"Inportant: be sure that you do not indent the first line.
.cgi For example,
myscript.cgi
chmod 755 filenameHere is an example of a shell script that has been modified in this way.
[echang@wyrd WWW]$ cat script2.cgi #!/bin/bash echo -e "Content-type: text/plain\n" echo "=================================" date finger echo -e "\n" echo "This is who:" who echo -e "\n" echo "=================================" echo "and this is a calendar:" cal echo "================================="
Here is a link to the example script. The URL is http://wyrd.hood.edu/~echang/script2.cgi
bash command, to be sure it works.Hood College Department of Computer Science: Course materials © 1997-2006 by Elizabeth Chang.