How to handle errors during script execution

Hi
I have written a script which returns a number. This resulting number I assign to the variable for example:

$ A=`get_dbnum 118 ttrn`
$ echo ${A}
8208
$

The script becomes interective once the error occures and the number is not found. It prompts the user to enter the number. The problem is that the prompts are not showing during the execution (I am not sure why) , the script hangs and all user prompts are getting assigned to the variable after abort, for example:

p338$ A=`get_dbnum 34 ttrn`
p338$ echo $A
POSSIBLE DUPLICATE ENTRIES IN /TSTMP/DBNUMBERS.NXT POSSIBLE SLOTS ARE: #29 #98 PLEASE CHECK THE FILE AND ENTER THE SLOT NUMBER OR Cntl-C TO EXIT>

Is there a way to make the prompts visible to the user? Any advice on how to handle similar issues....
Thanks a lot

Please show us the place in the code where you prompt the user and read input.
Can we assume the script runs interactively?