Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

OK, I just signed up with this SMALL hosting place and I m having problems running CGI's. The admin says its my script, not the server.

Heres the script(s) variations ive tried:
#!/usr/bin/perl /perl OR #!/usr/bin/perl OR #!/usr/local/bin/perl #use CGI::Carp qw(fatalsToBrowser); #use CGI; #$q = new CGI; #print $q->header(-type=>'text/html',-accept=>'*/*'); #print "Content-type: text/html\n\n"; print <<END; Content-type: text/html <html> </html> END

Tell me thats not BASIC to run on anything CGI?
I get these errors:
*****(I.E. error_log VIA server):******
[Fri May 17 15:58:45 2002] [error] [client 12.122. 366.335] Premature end of script headers: /home/virtual/blake/home/htt +pd/cgi-bin/test.cgi
*****and on the screen (I.E browser window):*****
Internal Server Error The server encountered an internal error or misconfiguration and was u +nable to complete your request. Please contact the server administrator, blah@blah.com and inform them + of the time the error occurred, and anything you might have done tha +t may have caused the error. More information about this error may be available in the server error + log.

*******Excerpt from the httpd.conf file:*******
<VirtualHost 12.34.56.788:80> ServerName www.blah.com ServerAlias blah.com *.blah.com ServerAdmin blah@blah.com DocumentRoot /home/virtual/blake/home/httpd/html User blake Group blake Redirect /admin https://blah.com:19638/webhost/services/virtualhos +ting/siteadmin Redirect /user https://blah.com:19638/webhost/services/virtualhost +ing/useradmin UserDir /home/virtual/blake/home/*/public_html AliasMatch ^/users/([^/]+)/?(.*) /home/virtual/blake/home/$1/publi +c_html/$2 ScriptAlias /cgi-bin/ /home/virtual/blake/home/httpd/cgi-bin/ CustomLog /home/virtual/blake/var/log/httpd/access_log combined ErrorLog /home/virtual/blake/var/log/httpd/error_log <Directory /home/virtual/blake/home/httpd/html/> Allow from all AllowOverride All Order allow,deny Options Includes </Directory> </VirtualHost>

also, any know the command to find the perl path(all in case) VIa telnet?

Any suggestions, except find a NEW host.
Charles
*yes they are uploaded VIA ftp Ascii

Replies are listed 'Best First'.
Re: OK, tell me WHY, this is only a hello world script
by UberDragon13 (Acolyte) on May 17, 2002 at 21:10 UTC
    Why not use the CGI.pm defaults to your advantage? The following code is taken right off of perldoc.com. It works under any normal circumstances.

    #!/usr/local/bin/perl use CGI qw/:standard/; # load standard CGI routines print header, # create the HTTP header start_html('hello world'), # start the HTML h1('hello world'), # level 1 header end_html; # end the HTML


    Also I think you need to have " around END in your example. And you definately do need two \n's after the Content Message if for some reason you don't just use header();
    print <<"END"; <html> </html> END
    I'm still pretty new here, but I just spent a good deal of time rewriting some code using the CGI.pm so its pretty fresh in my mind.

    ~UberDragon13

    ============================================================
    ....Sometimes life can be as bitter as dragon tears. But whether dragon tears are
    bitter or sweet depends entirely on how each person perceives the taste....
    ============================================================
      UD13,
      ++ for effort
      But, the quotes are not necessary. They are implied.
      Who says that programmers can't work in the Marketing Department?
      Or is that who says that Marketing people can't program?
Re: OK, tell me WHY, this is only a hello world script
by perlplexer (Hermit) on May 17, 2002 at 20:40 UTC
    To find out location of the Perl interpreter, you can use either 'which' or 'whereis'; e.g.,
    %which perl %whereis perl
    Provided that Perl is installed and you know it's location, the following should work
    #!/perl/is/here/perl -w use strict; use CGI; my $q = new CGI; print $q->header(); print "<b>Howdy!</b>";
    --perlplexer
Re: OK, tell me WHY, this is only a hello world script
by lshatzer (Friar) on May 17, 2002 at 20:39 UTC
    I belive you need two new lines after Content-type.
    Updated: And follow the directions perlplexer and Chady gave, as it might help also.
Re: OK, tell me WHY, this is only a hello world script
by Chady (Priest) on May 17, 2002 at 20:40 UTC

    Have you chmoded the script as executable?

    chmod 755 test.cgi

    although your cgi-bin should take care of that. As for the perl path, maybe you can try: which perl


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/