in reply to Wanting Validation for Smacking my Sysadmin (500 error problem)

Hi Petras,

could it be that you simply need to include,

print "HTTP/1.1 200 OK"
change your first line (now second line) to:
print "Content-type: text/html\n\n";
or if all else fails, unbuffer STDOUT:
local STDOUT; select((select(STDOUT), $|++)[0]);
The permissions on the script are OK, if a bit overly generous (755 would do, or even 555). The Perl script does get executed (hence the 'Premature end of script headers', otherwise you'd get a variation on 'Command interpreter not found'), so you're looking at a problem with the script itself.

Update: Oh, and it's never a good idea to go around smacking sysadmins. They usually have way bigger things to smack you back with, especially the ones of the BOFH variety :).

CU
Robartes-

Replies are listed 'Best First'.
Re: Wanting Validation for Smacking my Sysadmin (500 error problem)
by Petras (Friar) on Jan 23, 2003 at 14:20 UTC
    The bit of code

    local STDOUT; select((select(STDOUT), $|++)[0]);

    threw back a 'can't modify constant' error. BUT,

    print "HTTP/1.1 200 OK"

    made the script work fine (well, I never tried it verbatim--I added a semicolon to the end c",) )

    So I should probably be happy (which I am), but now you've got to tell me what the little snippet means.

    Thanks! -Petras
      The snippet unbuffers the I/O to STDOUT, by setting $| to true. Running it, I just noticed that you can't do local STDOUT;, as STDOUT is not a variable, but a constant referring to file descriptor 1. The snippet works without that part.

      What it does, working inside out, is:

      $|++;
      set currently selected file descriptor to unbuffered I/O
      select(STDOUT);
      make STDOUT currently selected file descriptor. This returns the previously selected FD.
      select ( ( select(STDOUT),$++)[0]);
      Select the first value in the list (select(STDOUT),$|++), which is the return value of select(STDOUT), which is the previously selected file descriptor.

      The snippet basically sets STDOUT to unbuffered I/O whilst preserving the previously selected filehandle as selected. Have a look in perlfaq for a better explanation.

      CU
      Robartes-