How To Flush User Input Before READ()

Home » Asterisk Users » How To Flush User Input Before READ()
Asterisk Users 7 Comments

Hi

how to flush user input before READ()?

I wrote a small script to ask for user password before granting access to outside, but some telefones memorize the full user input, including “#”.

So, when the user press redial, for instance 5556789#123, asterisk accepts the number and the password “123” and gives access to the outside word to whomever redials that terminal.

Any hints?

Cheers

Ethy

7 thoughts on - How To Flush User Input Before READ()

  • How about a read() to a dummy variable with a 1 second timeout to consume the octothorpe and password?

  • To close the thread, the solution did “flush” the input as a side effect of the short timeout.

    Thank you mr. Edwards.

    Cheers

    Ethy

  • If 1 second is too long, you could write an AGI to use the ‘wait for digit’ AGI command which allows the timeout to be specified in milliseconds.

  • If I understand it the OP has un-consumed input and is just looking for the shortest possible time to read it. Would a read with a timeout of zero do the job or would Asterisk optimize away the call?

  • Good idea. I was looking at the ‘read()’ dox for 1.2 which doesn’t say much about the timeout values — only that if it is 0, the default is used. The default may be changed using the TIMEOUT() function. Maybe setting the default to 0 and specifying 0 in read() may be fruitful.

    More modern Asterisks (11.17) say the timeout can be a floating point number. Maybe setting it to 0.1 (or 0.01) may do the trick.

    Unfortunately, I don’t have the time to play right now.