FAQ: Internal Server Error / Premature End of Script Header / MS-DOS Carriage Return
This FAQ is for people who experienced Internal Server Error on running their Perl script. Hopefully it won't be as tormenting an experience to you as it was to me.
------------------------------------------------------------ One of the most common errors in executing a Perl script is due to the CR/LF problem (i.e. existence of MS-DOS carriage returns in the script). What happens when there is a MS-DOS carriage return in your Perl script? INTERNAL SERVER ERROR The server encountered an internal error or misconfiguration and was unable to complete your request. What does the error log says? (location in redhat linux: /etc/httpd/logs/error_log ) Premature end of script header How do I check if I have MS-DOS carriage returns in my perl script? Go to telnet command line and use vi editor to check. vi -b filename.pl ^M means MS-DOS carriage return (tip: type :q! to exit vi editor) How do I fix it? You can add -w to #!/usr/bin/perl (i.e. #!/usr/bin/perl -w). This seems to be a temporary solution only. The permanent solution is to delete all MS-DOS carriage returns in the script. Donboy's suggestion: "Easiest way (for me, anyway) is to use a text editing program that allows you to change it quickly. I'm using Edit Plus from www.editplus.com. This is a text editor that is like an "advanced" notepad. You can go into the "document" pulldown and look for CR/LF and change it to Unix. it will quickly change those returns into their unix equivalent." Another way is to write and CHMOD 777 a simple perl script to delete the carriage return (make sure you write this script without MS-DOS carriage return!). Code:
#!/usr/bin/perl |
Re: FAQ: Internal Server Error / Premature End of Script Header / MS-DOS Carriage Ret
Quote:
You should submit this as a Tutorial here > http://www.linuxquestions.org/questions/answers.php where it won't go away because it's not a "sticky". :) |
Use dos2unix/unix2dos :)
|
All times are GMT -5. The time now is 11:20 AM. |