Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CGI bin file downloads instead of executing through HTML Browser

Status
Not open for further replies.

hrlabs

Newbie level 4
Joined
Apr 10, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,346
I am Embedded Software Engineer, I am new to Embedded Web Server programming, I wrote the HTML code which is simple form as the code shown below :


Code HTML5 - [expand]
1
2
3
4
5
<form action="/cgi-bin/gpio.cgi" method="post">
<div><label>Multiplicand 1: <input name="m"></label></div>
<div><label>Multiplicand 2: <input name="n"></label></div>
<div> <input type="submit"   value="Multiply" ></div>
</form>



and i wrote the following gpio.cgi code in C langugae to run it on Linux through my HTML :

here is the code shown below :


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int main() {
char *data ;
long  m,n;
printf("%s %c%c\n ", "Content-Type:text/html;charset=iso-8859-1",13,10);
printf("<title>Multiplication results</title>\n");
printf("<h3>Multiplication results</h3>\n");
data=getenv("QUERY_STRING");
if (data==NULL) 
 
printf("<P>Error! Error in passing data from to Script");
 
else if (sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)
 
printf("<P>Error! invalid Data. ");
 
else printf("<P>The Product of %ld and %ld is %ld.",m,n,m*n);
 
return 0;
 
}



Than i compiled my above program by typing following command in teminal in Linux:

gcc -o gpio.c gpio.cgi

and i put this gpio.cgi file in /cgi-bin directory the same path as i wrote in HTML code,

but when i click Submit button after entering data , my gpio.cgi file gets download instead of execution, while i tested gpio.cgi file independently and it works fine but not with HTML browser.

please help me i am really stucked with it.
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top