Asterisk bash script read digit

I’m not sure I’m following what you want to do…

You play ob1.
You read a ‘#’ terminated string of digits into a variable named digits.
You execute a Bash script, passing a variable named digit (not digits?) and write the output to a log file.
You hang up.

How do you think your script is telling Asterisk if digit is something or not?

Where in your dialplan do you do anything to listen to announcement A or B?