Normally you want a script to behave the same regardless of whether input comes from a keyboard or a file, or whether output is going to the screen or a file.
Occasionally, though, you want to make that distinction.
How do you do that in a script?
Use the test -t option in an if statement to branch between the two desired behaviors.
Think long and hard before you do this.
So much of the power and flexibility of bash scripting comes from the fact that scripts can be pipelined together.
Be sure you have a really good reason to make your script behave oddly when input or output is redirected.