In any perl script, the first line is to indicate the location of perl. Typically, it looks like the following:
Recently, i create a perl script to validate the Recaptcha. However it always gives me 500 Internal Server Error. At first I thought there is something wrong with my script. So I keep checking and checking and still can’t find out the error. So i just change the script to the following simple script that just print out a simple page.
#!/usr/bin/perl use strict; use CGI; my $query = new CGI; print $query->header( "text/html" ); print <
However, it still gives me 500 Internal Server Error. In the end, it turns out that the error is because of the first line. #!/usr/bin/perl This script is created in windows and uploaded to unix server. In windows the next line is \r\n. However in linux the next line is \n. So the first line becomes #!/usr/bin/perl\r in unix. Of cause, you won’t be able to see this changes since \r is not a character that can be displayed. Thus if you directly run the script in unix, the error is “bad interpreter”. In order to solve this, you need to convert the script you generated in windows back to unix format. It can be done using UltraEdit. Under Files, there is a function called Convertion, where you can convert files between different format.
Read the rest of this entry »