char line[80];
/* use line buffering */
setlinebuf(stdout);
setlinebuf(stderr);
/* read and ignore AGI environment */
while (1) {
fgets(line,80,stdin);
if (strlen(line) <= 1) break;
}
/* Send asterisk a command */
printf("SAY NUMBER 225 \"\"\n");
printf("WAIT FOR DIGIT -1\"\"\n");
/* Read response from Asterisk and show on console */
fgets(line,80,stdin);
fputs(line,stderr);
but it still does not execute the command, and the script ends immediately.
this is what i get the asterisk prompt:
Originator*CLI>
– Registered SIP ‘100’ at 172.16.1.207 port 25714 expires 3600
– Executing Wait(“SIP/100-ee29”, “”) in new stack
– Executing Answer(“SIP/100-ee29”, “”) in new stack
– Executing Dial(“SIP/100-ee29”, “SIP/105”) in new stack
– Called 105
– SIP/105-4b84 is ringing
– SIP/105-4b84 answered SIP/100-ee29
– Attempting native bridge of SIP/100-ee29 and SIP/105-4b84
== Spawn extension (agents, 999, 3) exited non-zero on ‘SIP/100-ee29’
– Executing DeadAGI(“SIP/100-ee29”, “test”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/test
AGI Tx >> agi_request: test
AGI Tx >> agi_channel: SIP/100-ee29
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1155752927.3
AGI Tx >> agi_callerid: 100
AGI Tx >> agi_calleridname: 100
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 999
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: agents
AGI Tx >> agi_extension: h
AGI Tx >> agi_priority: 1
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << SAY NUMBER 123 “”
– Playing ‘digits/1’ (language ‘en’)
– Playing ‘digits/hundred’ (language ‘en’)
– Playing ‘digits/20’ (language ‘en’)
– Playing ‘digits/3’ (language ‘en’)
AGI Tx >> 200 result=0
– AGI Script test completed, returning 0
– Executing Hangup(“SIP/100-ee29”, “”) in new stack
== Spawn extension (agents, h, 2) exited non-zero on ‘SIP/100-ee29’
– Unregistered SIP ‘100’
– Unregistered SIP ‘105’
if i use this: printf(“WAIT FOR DIGIT “-1” “”\n”);
it gives the following error at the asterisk prompt:
AGI Rx << WAIT FOR DIGIT “-1” ""
AGI Tx >> 520-Invalid command syntax. Proper usage follows:
AGI Tx >> Usage: WAIT FOR DIGIT
Waits up to ‘timeout’ milliseconds for channel to receive a DTMF digit.
Returns -1 on channel failure, 0 if no digit is received in the timeout, or
the numerical value of the ascii of the digit if one is received. Use -1
for the timeout value if you desire the call to block indefinitely.
AGI Tx >> 520 End of proper usage.
I have the same problem. Running on Debian, using AGI via PHP, no zaptel hardware, all SIP-based. Using ztdummy, which I am aware is to resolve timing problems. (lists.alioth.debian.org/pipermai … 05804.html)
Furthermore, I’ve had some problems with audio commands not playing any audio. It is my suspicion that the AGI pipe gets messed up sometimes; it doesn’t seem very robust.
This thread is stale, and I’d really like to see someone from the community step up and investigate this. It’s a pretty big issue for me, because I must run my code in a busy loop checking for digits, because I have my code behave as if result=1 is the same as a timeout, but really asterisk actually returns immediately. It’s quite a busy loop!
Code snippet:
Error snippet:
My specifications:
running Debian linux 2.6.18-6-686 on Dell 1600SC
Asterisk 1.6.0.1
PHP 5.2.0-8+etch15 (cli) … not that it should matter
Module Size Used by
ztdummy 3624 0
zaptel 183364 1 ztdummy[/code]