Python bekomme ich nicht ans laufen. Fehler: script not found or unable to stat: /usr/lib/cgi-bin/pytest.py

  • Hallo!


    Ich bekomme Python bei mir leider nicht ans laufen. Ich bekomme in der error_log immer folgende Fehlermeldung:


    ...script not found or unable to stat: /usr/lib/cgi-bin/pytest.py


    Das Python-Programm wird wohl im falschen Verzeichnis gesucht. Wie kann ich nun einstellen, dass das Python-Programm in meinem cgi-bin-Verzeichnis gesucht werden soll?


    Das hier ist übrigens das Programm:


    #!/usr/bin/python

    # -*- coding: UTF-8 -*-

    print "Content-Type: text/plain;charset=utf-8"

    print "Hello World!"


    Viele Grüße,

    masr

  • Versuchs mal mit

    Python
    #!/usr/bin/python
    
    # -*- coding: UTF-8 -*-
    
    print "Content-Type: text/plain;charset=utf-8"
    print
    print "Hello World!"

    Siehe Python(2) docs bzgl. Trennung von Header und body: https://docs.python.org/2/library/cgi.html

    "The output of a CGI script should consist of two sections, separated by a blank line. The first section contains a number of headers, telling the client what kind of data is following. Python code to generate a minimal header section looks like this:"

    Code
    print "Content-Type: text/html"     # HTML is following
    print                               # blank line, end of headers


    Edit:

    Ich habe etwas spät gelesen, dass du sagtest das Script wird nicht gefunden. Da mir die fehlende blank line aufgefallen ist, hab ich wohl den Text nur noch überflogen.

    Sollte das File wirklich nicht gefunden werden und es nicht an dem Script liegen, kann ich leider gerade nicht helfen. Sorry :/

  • Ja, das Script wird tatsächlich nicht gefunden. Ich hatte auch erst ein zusätzliches print drin und da hatte es auch nicht funktioniert. Das doppelte print hatte ich fälschlicherweise unbewusst gelöscht, weil es doppelt aussah.


    Weiß vielleicht jemand, wie ich einstellen kann, in welchem Verzeichnis das cgi-bin-Script gesucht werden soll?