Perl or Python script not working

Perl and Python scripts can be run as CGI applications.

If you get an error while trying to execute the script «500 Internal server error», make sure the following conditions are met:

  1. The access rights to the directory where the script is placed must be 750 or rwxr-x—.
  2. The script permissions must be 750 or rwxr-x—.
  3. There should be no special characters after the path to the interpreter. Line feed must be in UNIX format - \nand not in Windows format - \r\n.
  4. At the beginning of the file, an interpreter must be specified that will process the script.
  5. If the script is supposed to output something to the browser, at the beginning of the script you need to insert a line that displays the title Content-Type: text/html and one blank line.
  6. There must be an empty line at the end of the file.
For a Python script with the name index.py as an index file, you must either rename it to index.cgior add to .htaccess directive DirectoryIndex index.py.
print "Content-type:text/html\n\n";
print "Hello, World!";
print " ";
print "Content-Type: text/html\n\n"
msg = "Hello, World!"
print """%s""" % msg
print("Content-Type: text/html\n\n")
msg = "Hello, World!"
print("""%s""" % msg)