END; require_once "include/calendar.php"; require_once "include/planner-include.php"; require_once "include/header.inc.php"; ?>


Work on the following exercises individually. You are allowed to consult general shell scripting references such as the Advanced Bash Scripting Guide and the Bash Programming Introduction HOWTO (both at http://www.tldp.org) and search the Internet, but try as much as possible to solve the exercises on your own, referring to the man pages, apropos database, and slides as needed.

Don't worry about getting stuck. Try as hard as you can to finish the exercises on your own. If you find yourself at a dead end, write down everything you tried to do and e-mail me. If I don't reply within the weekend, at least you'll have questions for class on Wednesday.

E-mail me a tar.gz containing all your shell scripts and whatever notes you might have by 11:59:59 PM on Tuesday, December 9, 2003. Please feel free to e-mail me before then. (In fact, you are strongly encouraged to do so.)


hello-world.sh: echo

Write a shell script that, when invoked with ./hello-world.sh, prints out

Hello, world!
- your name here <your e-mail address>
(Substitute your name.)

hello-person.sh: arguments, echo

Write a shell script that, when invoked with ./hello-person.sh name, prints out

Hello, name!
- your name here <your e-mail address>
Example: ./hello-person.sh Sacha by Foo Bar <foo@bar.com> should print out

Hello, Sacha!
- Foo Bar <foo@bar.com>

hello-people.sh: loops, arguments, echo

Write a shell script that, when invoked with ./hello-people.sh person1 person2 person3, prints out

Hello, person1!
Hello, person2!
Hello, person3!
- your name here <your e-mail address>
Your program should work for any number of people, not just three. You will need to learn about loops.

greet.sh: if, test, date, cut, command substitution, echo

Write a shell script that greets you "Good morning", "Good afternoon", or "Good evening" depending on the time.

greet-english.sh and greet-filipino.sh: arg0, if, test, date, cut, command substitution, echo

Write a shell script that changes its behavior depending on how it's called. greet-english.sh and greet-filipino.sh should have exactly the same source code, and should take no parameters or use external variables - just use $0. For greet-filipino.sh, choose between "Magandang umaga", "Magandang hapon", and "Magandang gabi" depending on the time.

missing.sh: if, test, loops, arguments, echo

Write a shell script that checks for missing files. For example, if ls reports the following files foo baz and you call your script with ./missing.sh foo bar baz qux, the script should print out

because those two files can't be found in the current directory.

package-scripts.sh: tar, gzip, date, command substitution, wildcards

To make it easier for you to submit your work, write a shell script that creates a tar.gz of all the files ending in '.sh' in the current directory. The filename of the resulting archive should be of the form "studentid-date-time.tar.gz". Example: 990577-2003.12.07-23.59.tar.gz . This shell script takes no arguments.

contact.sh: grep, cut, if, arguments, echo, etc.


./contact.sh add "First Name" "Last Name" email phone
Add the record to contacts.txt, creating it if necessary. See format of contact.txt for details.

./contact.sh remove data
Remove the record from contacts.txt

./contact.sh search data
Print out the records that match data, alphabetically sorted (last name, then first name). See output format for details.

Format of contact.txt

contact.txt should contain lines of the form

Last Name:First Name:e-mail:phone

Output format

Name:   First name Last Name
E-mail: email
Phone:  phone
A blank line separates entries.