Sunny Woo
2003-Jul-12 13:42 UTC
[Asterisk-Users] AGI script sample using bash shell script
Hi,
A quick and dirty (aka Rapid Application Developement) AGI script
implement using bash shell. No need to invoke a 10MB perl engine to
process simple asterisk agi scripts.
I found it to be very useful in learning the AGI interface. For example,
I learn that AGI won't execute the next command until you read the
results from STDIN.
Enjoy,
Sunny Woo
Solution Consultant
Avantnix
=========================== agi-test-bash.agi =====================#!/bin/bash
declare -a array
while read -e ARG && [ "$ARG" ] ; do
array=(` echo $ARG | sed -e 's/://'`)
export ${array[0]}=${array[1]}
done
# following variables are available from asterisk
echo $agi_request >&2
echo $agi_channel >&2
echo $agi_language >&2
echo $agi_type >&2
echo $agi_uniqueid >&2
echo $agi_callerid >&2
echo $agi_dnid >&2
echo $agi_rdnis >&2
echo $agi_context >&2
echo $agi_extension >&2
echo $agi_priority >&2
echo $agi_enhanced >&2
checkresults() {
while read line
do
case ${line:0:4} in
"200 " ) echo $line >&2
return;;
"510 " ) echo $line >&2
return;;
"520 " ) echo $line >&2
return;;
* ) echo $line >&2;; #keep on reading those Invlid command
#command syntax until "520 End ..."
esac
done
}
echo "1. Testing 'sendfile' ..." >&2
echo "STREAM FILE beep \"\""
checkresults
echo "2. Testing 'sendtext' ..." >&2
echo "SEND TEXT \"hello world\""
checkresults
echo "3. Testing 'sendmage' ..." >&2
echo "SEND IMAGE asterisk-image"
checkresults
echo "4. Testing 'saynumber' ..." >&2
echo "SAY NUMBER 192837465 \"\""
checkresults
echo "5. Testing 'waitdtmf' ..." >&2
echo "WAIT FOR DIGIT 1000"
checkresults
echo "6. Testing 'record' ..." >&2
echo "RECORD FILE testagi gsm 1234 3000"
checkresults
echo "6a. Testing 'record' playback" >&2
echo "STREAM FILE testagi \"\" "
checkresults
echo "=================== Complete ====================" >&2
=========================== agi-test-bash.agi =====================
--
Sunny Woo <sunnywoo@yahoo.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: agi-test-bash.agi
Type: text/x-sh
Size: 1429 bytes
Desc: not available
Url :
http://lists.digium.com/pipermail/asterisk-users/attachments/20030712/fbaa3c8e/agi-test-bash.sh
faizan@tilizone.com
2003-Jul-12 15:48 UTC
[Asterisk-Users] AGI script sample using bash shell script
Quoting Sunny Woo <sunnywoo@yahoo.com>:> Hi, > A quick and dirty (aka Rapid Application Developement) AGI script > implement using bash shell. No need to invoke a 10MB perl engine to > process simple asterisk agi scripts. > > I found it to be very useful in learning the AGI interface. For example, > I learn that AGI won't execute the next command until you read the > results from STDIN. >Hey does that mean that whole perl script won execute or the next AGI command wont execute. Cuz may be I get this problem too.
Possibly Parallel Threads
- AGI STREAM FILE not working?
- Strange issues with new R-based 'R CMD build' and 'R CMD check' scripts on Windows
- how to detect dtmf in meetme
- 'R CMD INSTALL' keeps going on despite serious errors, and returns exit code 0
- 'R CMD INSTALL' keeps going on despite serious errors, and returns exit code 0