DistributedNetworks DistributedNetworks


Unix Commands  «Prev  Next»
Lesson 5 Data handling errors
Objective Describe how to handle incorrect user input.

Data handling errors (incorrect user input)

Data handling errors occur when a user enters incorrect or unexpected input.
These are notreally errors because your program will still work if your user enters the expected input. Data handling errors do not show up until the program is run later using the bad input. This might include a user typing a space where it doesn't belong or typing a word when your program is expecting a number. When writing your shell script, decide how much input checking to include in your code. You can decide to:
  1. Allow the program to fail if a user enters bad input. This saves you time programming, but aggravates the user.
  2. Check for some of the possible bad inputs, but not all.
  3. Handle every possible bad input. This saves the user aggravation, but uses a lot of programming time.
This lesson listed your choices for handling the situation. We will look at specific examples of handling bad user input later in this module.
The next lesson examines two common problems with user input, and how write your code to work around these problems.