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

shawn bright nephish at gmail.com
Mon Aug 14 08:46:23 MST 2006


yep, the problem was in the regular expression (only looks for a number 0-9)
i added a couple of lines that see if its not a number, but is a *  it will
return that.
thanks, not an asterisk issue, but a python issue.

shawn

On 8/14/06, Tzafrir Cohen <tzafrir.cohen at xorcom.com> wrote:
>
> On Mon, Aug 14, 2006 at 10:31:30AM -0400, shawn bright wrote:
> > lo there,
> > i am running a python agi script that gets a DTMF number from the user
> > and passes it back to the script.
>
> Any reason you're not using Read for this?
>
> > It works fine with numbers, but if they
> > enter a star (*), it doesn't want to play.
>
> Could you please provide a trace of the run?
>
> > 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):
>
> Just a hunch:
>
> How is '*' considered in a regular expression?
>
> >        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
>
> > _______________________________________________
> > --Bandwidth and Colocation provided by Easynews.com --
> >
> > asterisk-users mailing list
> > To UNSUBSCRIBE or update options visit:
> >    http://lists.digium.com/mailman/listinfo/asterisk-users
>
>
> --
> Tzafrir Cohen         sip:tzafrir at local.xorcom.com
> icq#16849755          iax:tzafrir at local.xorcom.com
> +972-50-7952406          jabber:tzafrir at jabber.org
> tzafrir.cohen at xorcom.com     http://www.xorcom.com
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20060814/be577545/attachment.htm


More information about the asterisk-users mailing list