CSCI-230: Linux Class Exercise

CSCI-230: Linux Class Exercise

CSCI-230: Linux Class Exercise

Objective: Gain familiarity with the Linux OS and some of its basic functionalities.

Using a text editor (such as emacs), create a data file called book.addrin your home directory with appropriate permissions so that the owner can modify and view the file, group members can view it, and others have no access. This file is an address book and should contain entries for people;e.g., you might have the following entry for me: (entries are formatted as:First_NameLast_NameTitle Phone#)

Jim Schnepf Associate Professor Phone: 363-2837

Note that each entry is a single line. Include at least 5 entries in the file. (Don't include any blank lines or any comment lines.)

Create a csci230bindirectory within your CSCI230 on your home directory (using mkdir command), with appropriate permissions so you have access to all files within, group members have read-only access, and others have no access.

We are going to place executable shell scripts inside folder CSCI230/csci230binso we need to add CSCI230/csci230binto the$PATHsystemvariable in order for shell to locate those scripts when called withouthavingthe user to type the complete path every time.When updating the PATH variable, make sure you don’t erase the old value (otherwise shell won’t be able to find other programs). Issue a command such as (provided that your CSCI230/csci230binis on your home):
setenv PATH ~/CSCI230/csci230bin:$PATH

Using theeditor, create another file called lookup(a shell script) in your csci230bindirectory with appropriate permissions (so you can view, modify and execute your script, group members can view and execute your script, and others have no access).When run, lookup should find entries (lines) in your book.addrfile matching any of the specified parameters and display them. For example, lookup Schnepfshould display any line (the whole record) that contains the string Schnepf. The output MUST be sorted. (HINT: use grep, sort, and script parameters). PS: Run the script from your home directory where the book.addr file is located. Your lookup script should execute properly ONLY IF the user specifies a single parameter (error messages must be displayed in other cases to notify the user of the EXACT problem (i.e. either too fee or too many parameters)).

It is much easier to solve the abovepartusing the command line first; only afterwards put the commands into the lookupscript.You can try to search for some specific name in your book.addr file at the command line, say Schnepf. When you get the search to work properly, add the command to sort the result. When this works, just put that command line in your ~/CSCI230/csci230bin/lookup file (where ~ represents your Linux home directory), add a comment to describe every line in your shell script, make that file executable, and try it out. The result should be exactly the same as when you ran the commands from the command line. Finally change Schnepf to a parameter so your lookupcommand will find other people too. Add creative extras if you like!.

Create another shell script file called SearchTarEmail(with appropriate comments to describe every script line) in the csci230bin directory that

  1. searches for all files (only) in your home directory, having a .addr extension which have been modified within the last 30 days,
  2. zips all those files into one folder,
  3. places the zipped folder in your csc230bin folder,
  4. cleans thecsci230bin directory by searching and removing all temporary files ending with a ~,
  5. tars the csci230bin directory as csci230bin.tar,
  6. and, finally,opens the pine mail softwareto enable you to email the tarred folder to me () (and CC yourself) and with other proper email information (i.e. subject, attachments and body).

(If your script gets stuck, you can exit it by pressing ^andc simultaneously.)