Chapter Review


[Page 293 (continued)]

Checklist

In this chapter, I described:

  • the creation of a Korn shell startup file

  • aliases and the history mechanism

  • the built-in vi and emacs line editors

  • arithmetic

  • functions

  • advanced job control

Quiz

1.

Why is the alias mechanism useful?

2.

How can you re-edit and re-execute previous commands?

3.

Does the Korn shell support recursive functions?

4.

How can you find a list of signals supported by the kill built-in command?

5.

Which shell variable contains the name of the shell startup file?

6.

Describe the two forms of arithmetic expressions supported by the Korn shell.

7.

How do you make a shell variable accessible to a subshell?

8.

What command is used to catch signals in a shell script?


[Page 294]

Exercises

1.

Rewrite the junk script of this chapter to be menu driven. Use the select command. [level: easy]

2.

Write a function called dateToDays that takes three parametersa month string such as Sep, a day number such as 18, and a year number such as 1962and returns the number of days from Jan 1 1900 to the date. [level: medium]

3.

Create a script called pulse that takes two parametersthe name of a script and an integer. pulse should execute the specified script for the specified number of seconds, suspend it for the same number of seconds, and continue this cycle until the specified script is finished. [level: hard]

Projects

1.

Write a skeleton script that allows system administration tasks to be performed automatically from a menu-driven interface. Useful tasks to automate include:

  • automatic deletion of core files

  • automatic warnings to users that use a lot of CPU time or disk space

  • automatic archiving

Don't worry about making them do anything just yet; we'll fill this in at the end of Chapter 14, "System Administration." For now, concentrate on making the menu and task selection work properly and just use the echo or print commands to print out what would happen for each selection. [level: easy]

2.

Write an alias manager script that allows you to choose DOS emulation, VMS emulation, or none. [level: medium]




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net