[asterisk-users] prob with star input agi-bin

shawn bright nephish at gmail.com
Mon Aug 14 07:31:30 MST 2006


lo there,
i am running a python agi script that gets a DTMF number from the user
and passes it back to the script. It works fine with numbers, but if they
enter a star (*), it doesn't want to play.
Is there a difference in how this is handled?
here is the snippit:

def getNumber (sound, gTimeLimit, digit_count):
    """
    the asterisk function GET DATA
    (filename, timeout, maxdigits)
    plays audiofile filename,
    gets DTMF digits
    up to timeout or max digits
    """
    digit_count = int(digit_count)
    time_limit = int(gTimeLimit)
    sys.stderr.write("GET DATA %s %d %d\n" % (sound, time_limit,
digit_count))
    sys.stderr.flush()
    sys.stdout.write("GET DATA %s %d %d\n" % (sound, time_limit,
digit_count))
    sys.stdout.flush()
    result = sys.stdin.readline().strip()
    result = checkResult(result)
    if result:
        return result
    else:
        sys.stderr.write('dead result from IVR')
        return 'error'

def checkResult(params):
    """
    reads the result of an asterisk command
    parses the answer and reports
    whether or not the command is successful
    """
    params = params.rstrip()
    if re.search('^200',params):
        result = re.search('result=(\d+)', params)
        if (not result):
            sys.stderr.write("FAIL ('%s')\n" % params)
            sys.stderr.flush()
            return -1
        else:
            result = result.group(1)
            sys.stderr.write('PASS (%s)\n' % result)
            sys.stderr.flush()
            return result
    else:
        sys.stderr.write("FAIL (unexpected result '%s')\n" % params)
        sys.stderr.flush()
        return -2

menu_result = getNumber('menu', 5000, 1)

any idea where i may be missing something here ?
some of the code is from an example app that i found on the internet.
There is something in this code ( i suppose ) that limits me from getting
anything but an integer as a response from here

if you have read this far, thanks for your time.

shawn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20060814/b6e325b0/attachment.htm


More information about the asterisk-users mailing list