Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trying to run a simple CGI. Please help. Full source.

5 views
Skip to first unread message

JKE

unread,
Jun 7, 2000, 3:00:00 AM6/7/00
to
I have a test page:

<FORM ACTION="http://mypage.whatever.com/cgi-bin/test.pl">
<P>Please specify the multiplicands:
<INPUT NAME="m" SIZE="5">
<INPUT NAME="n" SIZE="5"><BR>
<INPUT TYPE="SUBMIT" VALUE="Multiply!">
</FORM>


The "test.pl" is Borland C 4.53 dos exe renamed to test.pl (my site provider FAQ
said all scripts should be *.pl whether they are actually exes or perl):

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
char *data;
long m,n;
printf("%s%c%c","<html>",13,10);
printf("%s%c%c","<head>",13,10);
printf("<title>Multiplication results</title>\n");
printf("%s%c%c","<meta http-equiv=\"Content-Type\" content=\"text/html;
charset=iso-8859-1\">",13,10);
printf("%s%c%c","</head>",13,10);
printf("%s%c%c","<body bgcolor=\"#FFFFFF\">",13,10);
printf("Multiplication results\n");
data = getenv("QUERY_STRING");
if(data == NULL)
printf("Error! Error in passing data from form to script.\n");
else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)
printf("Error! Invalid data. Data must be numeric.\n");
else
printf("The product of %ld and %ld is %ld.\n",m,n,m*n);
printf("%s%c%c","</body>",13,10);
printf("%s%c%c","</html>",13,10);
return 0;
}

But when I press the "multiply" button on the test.htm page I get the following
error:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP
headers. The headers it did return are:

Unrecognized character \240 ignored at F:\jfdjdfh\cgi-bin\testi.pl line 1.
Array found where operator expected at F:\\jfdjdfh\cgi-bin\testi.pl line 1, near
""
(Missing operator before ?)
syntax error at F:\\jfdjdfh\cgi-bin\testi.pl line 1, near ""
Unrecognized character \377 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \377 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \002 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \007 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \200 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \001 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \373 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
Unrecognized character \001 igno


What am I doing wrong?
--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content. You can SELF-APPROVE your first posting
by writing the word 'passme' on a line by itself.

Drew Simonis

unread,
Jun 7, 2000, 3:00:00 AM6/7/00
to
: #include <stdio.h>

: #include <stdlib.h>
:
: int main(void)
: {
: char *data;
: long m,n;
: printf("%s%c%c","<html>",13,10);
: printf("%s%c%c","<head>",13,10);
: printf("<title>Multiplication results</title>\n");
: printf("%s%c%c","<meta http-equiv=\"Content-Type\" content=\"text/html;


2 things I notice here. First, your header is AFTER the html
and head tags, should be before. Second is that it needs to be
followed by 2 newline charachters. (usually \n).

Mark Lybrand

unread,
Jun 7, 2000, 3:00:00 AM6/7/00
to
And it probably won't work as an HTML <meta> tag.

Mark :)

"Drew Simonis" <car...@attglobal.net> wrote in message
news:393E5335...@attglobal.net...
: : #include <stdio.h>

JKE

unread,
Jun 8, 2000, 3:00:00 AM6/8/00
to
Drew Simonis <car...@attglobal.net> wrote:

:: #include <stdio.h>


:: #include <stdlib.h>
::
:: int main(void)
:: {
:: char *data;
:: long m,n;
:: printf("%s%c%c","<html>",13,10);
:: printf("%s%c%c","<head>",13,10);
:: printf("<title>Multiplication results</title>\n");
:: printf("%s%c%c","<meta http-equiv=\"Content-Type\" content=\"text/html;
:
:
:2 things I notice here. First, your header is AFTER the html
:and head tags, should be before. Second is that it needs to be
:followed by 2 newline charachters. (usually \n).

I checked a few HTML pages and they all had a similar composition like mine.

I'm just learning here and just want a "hello world" type of html page to
display.

I'll change the exe to write a htm page on the server and then make the browser
jump there. What is the HMTL or CGI command that the exe should printf()?

Michael Wines

unread,
Jun 8, 2000, 3:00:00 AM6/8/00
to
JKE wrote:
:
: Drew Simonis <car...@attglobal.net> wrote:
:
: :: #include <stdio.h>
: :: #include <stdlib.h>
: ::
: :: int main(void)
: :: {
: :: char *data;
: :: long m,n;
: :: printf("%s%c%c","<html>",13,10);
: :: printf("%s%c%c","<head>",13,10);
: :: printf("<title>Multiplication results</title>\n");
: :: printf("%s%c%c","<meta http-equiv=\"Content-Type\" content=\"text/html;
: :
: :
: :2 things I notice here. First, your header is AFTER the html
: :and head tags, should be before. Second is that it needs to be
: :followed by 2 newline charachters. (usually \n).
:
: I checked a few HTML pages and they all had a similar composition like mine.
:
: I'm just learning here and just want a "hello world" type of html page to
: display.
:
: I'll change the exe to write a htm page on the server and then make the browser
: jump there. What is the HMTL or CGI command that the exe should printf()?

Read this:
http://hoohoo.ncsa.uiuc.edu/cgi/primer.html

Message has been deleted

Drew Simonis

unread,
Jun 8, 2000, 3:00:00 AM6/8/00
to
Mark Lybrand wrote:
:
: And it probably won't work as an HTML <meta> tag.
:
: Mark :)

Sharp! I didn't even notice that.

Bill Moseley

unread,
Jun 8, 2000, 3:00:00 AM6/8/00
to
On 7 Jun 2000 06:52:46 -0600 Drew Simonis (car...@attglobal.net)
remarked...
: : #include <stdio.h>

: : #include <stdlib.h>
: :
: : int main(void)
: : {
: : char *data;
: : long m,n;
: : printf("%s%c%c","<html>",13,10);
: : printf("%s%c%c","<head>",13,10);
: : printf("<title>Multiplication results</title>\n");
: : printf("%s%c%c","<meta http-equiv=\"Content-Type\" content=\"text/html;
:
:
: 2 things I notice here. First, your header is AFTER the html
: and head tags, should be before. Second is that it needs to be
: followed by 2 newline charachters. (usually \n).

After? How about missing. That's a meta http-eqiv header, not an http
header.

Also, you don't need to print separate \n\r with most web servers -- the
server will rewrite the header and do that for you unless running nph?

--
Bill Moseley mailto:mos...@best.com
pls note the one line sig, not counting this one.

Ilmari Karonen

unread,
Jun 9, 2000, 3:00:00 AM6/9/00
to
In article <tgksjsk0c1hmsfm8m...@4ax.com>, JKE wrote:
:The "test.pl" is Borland C 4.53 dos exe renamed to test.pl (my site provider FAQ

:said all scripts should be *.pl whether they are actually exes or perl):
:
[C source snipped]
:
:Unrecognized character \240 ignored at F:\jfdjdfh\cgi-bin\testi.pl line 1.

:Array found where operator expected at F:\\jfdjdfh\cgi-bin\testi.pl line 1, near ""
: (Missing operator before ?)
:syntax error at F:\\jfdjdfh\cgi-bin\testi.pl line 1, near ""
:Unrecognized character \377 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.
:Unrecognized character \377 ignored at F:\jfdjdfh\cgi-bin\test.pl line 1.

Those errors are clearly from perl, hopelessly trying to parse a
binary file as a Perl script. I think your provider's advice is
complete and utter bullshit.

--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.

Drew Simonis

unread,
Jun 9, 2000, 3:00:00 AM6/9/00
to
Ilmari Karonen wrote:
: Those errors are clearly from perl, hopelessly trying to parse a

: binary file as a Perl script. I think your provider's advice is
: complete and utter bullshit.

They must be the type that thing "CGI" eq "Perl"

0 new messages