help CGI in perl and C


G

gmclee

hi there,
I am trying to use CGI in my my homepage. The server is running in
win2003 and the network admin said it support ASP as well as
ActivePerl. I have no idea what CGI and perl is before I read a brief
introduction of CGI. I have written a simple perl to test if it works

#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "It works fine";
exit;

Of course, it works fine. However, I would like to write the CGI in C
language. I try the following code and compile it into test.exe,
renamed as test.cgi

#include <stdio.h>
int main(int argc,char ** argv,char ** arge)
{
printf("content-type:text/html\r\n\r\n");
printf("abc\r\n<br>");
return 0;
}

However, when I run the program. The server returns

'xxx\cgi-bin\test.cgi' script produced no output

Would anyone please tell me what's going on? Some one told me CGI is
just an interface and can be written in many languages. So why it works
fine for perl code but fail for C?????

Thanks in advance.
 
Ad

Advertisements

J

John Bokma

(e-mail address removed) wrote:

[ C (!) code ]
However, when I run the program. The server returns

'xxx\cgi-bin\test.cgi' script produced no output

Does it when called from the command line? Also, the C related group is
that way --->

Even though there are Perl programmers that can help you, if they do so,
where is the end? Your next question might be how to cook salmon.
 
U

Uri Guttman

LSX> John Bokma said:
(e-mail address removed) wrote:

[ C (!) code ]
However, when I run the program. The server returns

'xxx\cgi-bin\test.cgi' script produced no output

Does it when called from the command line? Also, the C related group is
that way --->

Even though there are Perl programmers that can help you, if they do so,
where is the end? Your next question might be how to cook salmon.

LSX> I write CGI in Perl, and my boss is coming to dinner. Do you have any
LSX> good salmon recipes that would show I know how to write good Perl
LSX> code? :)

i write perl and love to cook salmon. i just bought about 1lb of wild
salmon today from a great local fishmonger for $14/lb. i will probably
broil or grill it with possibly an herbed butter for a topping. yum! i
should write a cpan module on this.

uri
 
R

Richard

hi there,
I am trying to use CGI in my my homepage. The server is running in
win2003 and the network admin said it support ASP as well as
ActivePerl. I have no idea what CGI and perl is before I read a brief
introduction of CGI. I have written a simple perl to test if it works

#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "It works fine";
exit;

Of course, it works fine. However, I would like to write the CGI in C
language. I try the following code and compile it into test.exe,
renamed as test.cgi

#include <stdio.h>
int main(int argc,char ** argv,char ** arge)
{
printf("content-type:text/html\r\n\r\n");
printf("abc\r\n<br>");
return 0;
}

Well you should look at your own code in the perl example you wrote \n\n
and in the C version you do \r\n which is incorrect.

If you see simple samples you should try to copy them line by line:)
 
J

John W. Krahn

Uri said:
LSX> I write CGI in Perl, and my boss is coming to dinner. Do you have any
LSX> good salmon recipes that would show I know how to write good Perl
LSX> code? :)

i write perl and love to cook salmon. i just bought about 1lb of wild
salmon today from a great local fishmonger for $14/lb.

Pacific or Atlantic salmon?
i will probably
broil or grill it with possibly an herbed butter for a topping. yum! i
should write a cpan module on this.

The grocer I go to sells it pre-prepared marinated in herbs and lemon, I
usually bake it. Mmmmmmm, salmon!



John
 
J

John Bokma

Lawrence Statton XE2/N1GAK said:
John Bokma said:
(e-mail address removed) wrote:

[ C (!) code ]
However, when I run the program. The server returns

'xxx\cgi-bin\test.cgi' script produced no output

Does it when called from the command line? Also, the C related group
is that way --->

Even though there are Perl programmers that can help you, if they do
so, where is the end? Your next question might be how to cook salmon.

I write CGI in Perl, and my boss is coming to dinner. Do you have any
good salmon recipes that would show I know how to write good Perl
code? :)

use strict and use warnings for starters?

Or maybe tell that you looked at CPAN for recipes.
 
Ad

Advertisements

U

Uri Guttman

LSX> I write CGI in Perl, and my boss is coming to dinner. Do you have any
LSX> good salmon recipes that would show I know how to write good Perl
LSX> code? :)
JWK> Pacific or Atlantic salmon?

hard to find wild atlantic salmon in general so i suspect pacific. i
will ask the next time i see the perl^Wfish monger.

JWK> The grocer I go to sells it pre-prepared marinated in herbs and
JWK> lemon, I usually bake it. Mmmmmmm, salmon!

you are paying a big premium for that. i almost never buy premarinated
fish as it is too easy to do it yourself. tonight i have some sea
scallops from that monger (local from new england) marinating in olive
oil and crushed garlic (fresh of course!). in a few minutes i will broil
them to perfection!

uri
 
Ad

Advertisements

T

Tad McClellan

John Bokma said:
(e-mail address removed) wrote:

[ C (!) code ]
However, when I run the program. The server returns

'xxx\cgi-bin\test.cgi' script produced no output

Does it when called from the command line? Also, the C related group is
that way --->

Even though there are Perl programmers that can help you, if they do so,
where is the end? Your next question might be how to cook salmon.


Should you pronounce the "ell" in salmon, or is it silent?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top