HP3000-L Archives

July 1997, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Bixby <[log in to unmask]>
Reply To:
Date:
Fri, 25 Jul 1997 08:52:37 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (87 lines)
John Korb writes:
> I have a simple Perl script which works when executed directly from the
> shell (with input terminated by ":EOD"), but which hangs (apparently
> waiting on more input) when run from the web server.  The Perl script is
> very close to one in the Perl book I'm using and is included below.
>
> #!/usr/local/bin/perl
> #
> #  Test script to copy from STDIN to a file named TEMPHOLD.
> #
> $server=$ENV{'SERVER_SOFTWARE'};

Delete the following line; the web server generates this response for you:

> print "HTTP/1.0 200 OK\n";

Change the following line:

> print "Content-type: text/html\n";

To:

> print "Content-type: text/html\n\n";

Delete the following line; the web server generates this response for you:

> print "Server: $server\n\n";

Everything else should be OK.

> print "<HTML>\n";
> print "<head>\n";
> print "<title>\n";
> print "Display STDIN Contents\n";
> print "</title>\n";
> print "</head>\n";
> print "<body bgcolor=#FFFFFF>\n";
> print "<h1>STDIN Contents</h1>\n";
> print "Contents of STDIN will be written to /WWW/TEMP/TEMPHOLD.\n";
> open (OUTFILE, ">/WWW/TEMP/TEMPHOLD");
> while (<STDIN>) {
>         print OUTFILE;
>         }
> close OUTFILE;
> print "TEMPHOLD has been closed.\n";
> print "</body>\n";
> print "</html>\n";
> exit(0);
>
> The server error log shows that when the user eventually gives up and
> clicks "STOP" on the browser, the following two errors are reported:
>
> [Fri Jul 25 08:56:58 1997] killing CGI process 7602373
> [Fri Jul 25 08:57:01 1997] httpd: send timed out for korbj
>
> Nothing unusual there.
>
> When I check the /WWW/TEMP/TEMPHOLD file, it contains all of the data it
> should (form contents in this case).
>
> QUESTION:
> It appears that the Perl "while (<STDIN>)" test is not seeing an
> end-of-file on STDIN when it reaches the end of the data submitted by the
> form, but from the examples in the Perl and CGI books it appears that in
> "normal UNIX" implementations the above "while" SHOULD be seeing an
> end-of-file.
>
> Is this an implementation issue related to MPE/iX 5.5, or the NCSA server
> on 5.5, or am I misunderstanding the Perl and CGI books?

Perl syntax-wise, you're OK.  I think the extra headers printed by your script
were confusing the server.

BTW, you might have to check for a Content-length header passed via stdin, and
then only read that number of bytes subsequently.

While you can do this form reading stuff manually in Perl, it's much *much*
*MUCH* easier to do with Perl5 and the CGI.pm module:

        http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
--
Mark Bixby                      E-mail: [log in to unmask]
Coast Community College Dist.   Web: http://www.cccd.edu/~markb/
District Information Services   1370 Adams Ave, Costa Mesa, CA, USA 92626-5429
Technical Support               +1 714 438-4647
"You can tune a file system, but you can't tune a fish." - tunefs(1M)

ATOM RSS1 RSS2