RE: [Asterisk-Users] GET DATA and STREAM FILE commands, don´t work

Josh McAllister josh at singletouch.net
Mon May 15 11:40:14 MST 2006


 

> -----Original Message-----
> From: asterisk-users-bounces at lists.digium.com 
> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of 
> cleviton.araujo at caixa.gov.br
> Sent: Monday, May 15, 2006 8:19 AM
> To: asterisk-users at lists.digium.com
> Subject: [Asterisk-Users] GET DATA and STREAM FILE commands, 
> don´t work
> 
...
> 
> Now, below is my script in bash shell, scriptTest.bsh:
> 
> #!/bin/bash
> #echo -e "Testing the working GET DATA and STREAM FILE\n" >&2 
> echo -e "STREAM FILE demo-instruct \"\"\n"
> echo -e "GET DATA myprompt 4000 6\n"
> read getDigits
> echo -e "My Digits are: $getDigits\n" >&2 echo -e "HUNGUP\n"

The first thing asterisk does once it starts an AGI process is to send various details about the caller to your script's STDIN. You need to read all that in before issuing any commands.

Add the following to the top of your script:

declare -a array
while read -e ARG && [ "$ARG" ] ; do
	array=(` echo $ARG | sed -e 's/://'`)
	export ${array[0]}=${array[1]}
done

This will export various ENV variables containing the info asterisk is sending.

For more info look at the BASH resources on the Asterisk AGI page of voip-info.org. (http://www.voip-info.org/wiki-Asterisk+AGI)

Josh McAllister



More information about the asterisk-users mailing list