Error in AGI scripting in c language

hi to all
can anyone solve this problem
c language program ,extension in extensions.confg and error r given below

///////////////////////error displayed in cli////////////////
*CLI> – Registered SIP ‘Exam_controller’ at 192.168.0.16 port 40126 expires 3600
– Executing Answer(“SIP/Exam_controller-0a0f2750”, “”) in new stack
– Executing AGI(“SIP/Exam_controller-0a0f2750”, “zagi.c”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/zagi.c
AGI Tx >> agi_request: zagi.c
AGI Tx >> agi_channel: SIP/Exam_controller-0a0f2750
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1162503099.0
AGI Tx >> agi_callerid: Exam_controller
AGI Tx >> agi_calleridname: Exam_controller
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 555
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: employee
AGI Tx >> agi_extension: 555
AGI Tx >> agi_priority: 2
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
Failed to execute ‘/var/lib/asterisk/agi-bin/zagi.c’: Exec format error
– AGI Script zagi.c completed, returning 0
– Executing Hangup(“SIP/Exam_controller-0a0f2750”, “”) in new stack
== Spawn extension (employee, 555, 3) exited non-zero on ‘SIP/Exam_controller-0a0f2750’
– Incoming call: Got SIP response 500 “Server Internal Error” back from 192.168.0.16
– Registered SIP ‘PTD’ at 192.168.0.50 port 53910 expires 3600
– Unregistered SIP ‘PTD’

///////////////////////extension////////////////////////////

exten => 555,1,answer()
exten => 555,2,agi,zagi.c
exten => 555,3,hangup()

/////////////////// agi script in clanguage saved in
agi-bin folder///////////////////////

#include <stdio.h>
main()
{
char line[80];
int a=11,i;
setlinebuf(stdout);
setlinebuf(stderr);
while(1)
{
fgets(line,80,stdin);
if(strlen(line)<=1)
break;
}

for(i=1;i<=2;i++)
{
}

/////////////////////////////////////////////////

if anyone know about AGI scripting in c language so please tell me the requirments that i didn’t fulfill to run it.

positive response will be highly appreciated
ok bye

Did you compile the AGI on the machine where it’s running and giving you this error?

it looks like he’s trying to execute the C source code!

yes i used source code file .please tell me how to compile this source code
on a machine using fedora core 4 and asterisk.

C must be compiled to work. Check out gnu.org for tutorials on gcc and how to compile source code. If compiling C appears too complicated, switch to Perl and rewrite your AGI script using it. Perl scripts do not need to be compiled to run.

Look for tutorials on the web that describe how to write CGI (common gateway interface) programs. AGI is a lot like CGI. You’ll find many examples of Perl and C programs that implement the CGI. When you’ve had a little practice writing CGI, try applying what you’ve learned to AGI. It will then make a whole lot more sense.

for compiling c source code ,in which directory of gcc in fedora core 4 i should place c source code

please stop cross-posting this.