Re: more apache/perl problems, premature end of script
On Mon, Nov 27, 2000 at 12:18:29AM -0600, Herbert Ho wrote: i posted before w/ 400 forbidden problems. i fixed that, but i still can't get a script to run. i now get: Premature end of script headers: /home/herb/public_html/init/login.pl i'm pretty sure it's not my script since it works on another webserver that my university runs (and i can't find their conf files to compare). Don't be so sure... #!/usr/bin/perl -w require cgi-lib.pl; Do you have cgi-lib.pl installed? It's very old and icky. Look at /var/log/apache/error.log for the errors. -- CueCat decoder .signature by Larry Wall: #!/usr/bin/perl -n printf Serial: %s Type: %s Code: %s\n, map { tr/a-zA-Z0-9+-/ -_/; $_ = unpack 'u', chr(32 + length()*3/4) . $_; s/\0+$//; $_ ^= C x length; } /\.([^.]+)/g;
Re: more apache/perl problems, premature end of script
i downloaded cgi-lib.pl and placed it in the same directory as my script. (from cgi-lib.berkeley.edu) it runs fine on the cmdline (both my box and my university's server) the error i get in /var/log/apache/error.log is (without the time stamp): Premature end of script headers: /home/herb/public_html/init/login.pl what changes have to be made to a stock apache config on potato for cgi/perl to work in the user public_html directories? the changes i've made so far: 1) in access.conf (adding ExecCGI to the Options directive in the DirectoryMatch directive for the public_html directories) 2) in srm.conf (adding AddHandler cgi-script .pl .cgi) ## my script works in /usr/lib/cgi-bin/ but not in the public_html directories. i've tried copying the Directory directive for /usr/lib/cgi-bin word for word to the public_html directive w/ no effect. also i've tried this even without cgi-lib.pl, without any difference on my box (while it works on the university server). here's another simple script that i tried: #!/usr/bin/perl -w print Content-type: text/html\n\n; print EOF; htmlbody hi /body/html EOF thanks for everyone's help so far. i'm gonna get this to work...somehow. =) herbert On Sun, Nov 26, 2000 at 10:34:12PM -0800, brian moore wrote: On Mon, Nov 27, 2000 at 12:18:29AM -0600, Herbert Ho wrote: i posted before w/ 400 forbidden problems. i fixed that, but i still can't get a script to run. i now get: Premature end of script headers: /home/herb/public_html/init/login.pl i'm pretty sure it's not my script since it works on another webserver that my university runs (and i can't find their conf files to compare). Don't be so sure... #!/usr/bin/perl -w require cgi-lib.pl; Do you have cgi-lib.pl installed? It's very old and icky. Look at /var/log/apache/error.log for the errors.
Re: more apache/perl problems, premature end of script
welcome to the club, you've been initiated. On Mon, Nov 27, 2000 at 10:34:40AM -0600, Herbert Ho wrote: i downloaded cgi-lib.pl and placed it in the same directory as my script. (from cgi-lib.berkeley.edu) it runs fine on the cmdline (both my box and my university's server) the error i get in /var/log/apache/error.log is (without the time stamp): Premature end of script headers: /home/herb/public_html/init/login.pl what changes have to be made to a stock apache config on potato for cgi/perl to work in the user public_html directories? apache, when it runs a process that generates the stuff that'll be sent out to a client's browser, checks the text for completeness. this includes all the header fields, such as content-type: text/html connection: close date: 27 nov 2000 accept-ranges: bytes try this, now: telnet localhost 80 ^M GET / HTTP/1.1 ^M ^M localhost is whatever host your server's running on; the ^M merely denotes end-of-line/enter on your part. here's what you'll get back: HTTP/1.1 200 OK Date: yada-yada that first line is the STATUS for the whole request, which comes even before the header:value fields. so try this in your script: #!/usr/bin/perl print HTTP/1.1 200 OK\nContent-Type: text/html\n\n; print bhello world/bpit worked!; so what you're seeing is APACHE noticing that you didn't specify a HTTP STATUS CODE. from the perl.apache.org/guide/ website-- If you take a basic CGI script like this: print Content-type: text/plain\r\n\r\n; print Hello world; it wouldn't work, because the HTTP header will not be sent out. By default, mod_perl does not send any headers itself. You may wish to change this by adding PerlSendHeader On in the Apache::Registry Location section of your configuration. Now, the response line and common headers will be sent as they are by mod_cgi. Just as with mod_cgi, PerlSendHeader will not send the MIME type and a terminating double newline. Your script must send that itself the modperl guide (perl.apache.org/guide) offers a wealth of info, once you know what you're looking for... :) the changes i've made so far: 1) in access.conf (adding ExecCGI to the Options directive in the DirectoryMatch directive for the public_html directories) 2) in srm.conf (adding AddHandler cgi-script .pl .cgi) ## my script works in /usr/lib/cgi-bin/ but not in the public_html directories. i've tried copying the Directory directive for /usr/lib/cgi-bin word for word to the public_html directive w/ no effect. you need # something along the lines of... LoadModule userdir_module /usr/lib/apache/1.3/mod_userdir.so UserDir /home/*/public_html DirectoryMatch ^/home/.*/public_html/cgi-bin Options +ExecCGI /DirectoryMatch UserDir disabled root somewhere in your config, then. thanks for everyone's help so far. i'm gonna get this to work...somehow. =) -- There are only two places in the world where time takes precedence over the job to be done. School and prison. --William Glasser [EMAIL PROTECTED]***http://www.dontUthink.com/ volunteer to document your experience for next week's newbies -- http://www.eGroups.com/messages/newbieDoc
Re: more apache/perl problems, premature end of script (SOLVED)
thanks to everyone who's helped out on this. especially Will Trillich [EMAIL PROTECTED] for pointing me to perl.apache.org. wow. =) in any case. for posterity. in a stock apache-perl install on a potato, you have to add something like the following to access.conf: Files ~ \.pl$ SetHandler perl-script PerlHandler Apache::Registry PerlSendHeader On Options ExecCGI /Files a good resource is also the man page on going from cgi to perl (cgi_to_mod_perl). *sigh* it feels good to get it to work. =) thanks again everyone! herbert On Mon, Nov 27, 2000 at 02:59:09PM -0600, will trillich wrote: welcome to the club, you've been initiated. On Mon, Nov 27, 2000 at 10:34:40AM -0600, Herbert Ho wrote: i downloaded cgi-lib.pl and placed it in the same directory as my script. (from cgi-lib.berkeley.edu) it runs fine on the cmdline (both my box and my university's server) the error i get in /var/log/apache/error.log is (without the time stamp): Premature end of script headers: /home/herb/public_html/init/login.pl what changes have to be made to a stock apache config on potato for cgi/perl to work in the user public_html directories? apache, when it runs a process that generates the stuff that'll be sent out to a client's browser, checks the text for completeness. this includes all the header fields, such as content-type: text/html connection: close date: 27 nov 2000 accept-ranges: bytes try this, now: telnet localhost 80 ^M GET / HTTP/1.1 ^M ^M localhost is whatever host your server's running on; the ^M merely denotes end-of-line/enter on your part. here's what you'll get back: HTTP/1.1 200 OK Date: yada-yada that first line is the STATUS for the whole request, which comes even before the header:value fields. so try this in your script: #!/usr/bin/perl print HTTP/1.1 200 OK\nContent-Type: text/html\n\n; print bhello world/bpit worked!; so what you're seeing is APACHE noticing that you didn't specify a HTTP STATUS CODE. from the perl.apache.org/guide/ website-- If you take a basic CGI script like this: print Content-type: text/plain\r\n\r\n; print Hello world; it wouldn't work, because the HTTP header will not be sent out. By default, mod_perl does not send any headers itself. You may wish to change this by adding PerlSendHeader On in the Apache::Registry Location section of your configuration. Now, the response line and common headers will be sent as they are by mod_cgi. Just as with mod_cgi, PerlSendHeader will not send the MIME type and a terminating double newline. Your script must send that itself the modperl guide (perl.apache.org/guide) offers a wealth of info, once you know what you're looking for... :) the changes i've made so far: 1) in access.conf (adding ExecCGI to the Options directive in the DirectoryMatch directive for the public_html directories) 2) in srm.conf (adding AddHandler cgi-script .pl .cgi) ## my script works in /usr/lib/cgi-bin/ but not in the public_html directories. i've tried copying the Directory directive for /usr/lib/cgi-bin word for word to the public_html directive w/ no effect. you need # something along the lines of... LoadModule userdir_module /usr/lib/apache/1.3/mod_userdir.so UserDir /home/*/public_html DirectoryMatch ^/home/.*/public_html/cgi-bin Options +ExecCGI /DirectoryMatch UserDir disabled root somewhere in your config, then. thanks for everyone's help so far. i'm gonna get this to work...somehow. =)