J'ai ce script simple pour me connecter via ssh à un serveur et ça marche si je lance le script à partir du shell, mais ça ne fonctionne pas quand j'appelle le script de CGI -bin (http://localhost/cgi-bin/test.py)Impossible d'écrire dans PYTHON_EGG_CACHE à partir du script cgi Python à l'aide de XAMPP
#!C:\Python27\python
print "Content-type: text/html\n\n"
import spur
shell = spur.SshShell(hostname="192.168.1.5", username="user", password="pass", missing_host_key=spur.ssh.MissingHostKey.accept)
result = shell.run(["pwd"])
print result.output
J'utilise XAMPP sous Windows et j'édité le httpd.conf d'accepter .py fichiers de cgi-bin, InFACT un simple
#!C:\Python27\python
print "Content-type: text/html\n\n"
print "Test"
œuvres dans le navigateur.
L'erreur trouvée dans mes logs Apache est la suivante:
Traceback (most recent call last):
File "C:/xampp/cgi-bin/smart.py", line 4, in <module>
import spur
File "C:\\Python27\\lib\\site-packages\\spur\\__init__.py", line 2, in <module>
from spur.ssh import SshShell
File "C:\\Python27\\lib\\site-packages\\spur\\ssh.py", line 15, in <module>
import paramiko
File "build\\bdist.win32\\egg\\paramiko\\__init__.py", line 30, in <module>
File "build\\bdist.win32\\egg\\paramiko\\transport.py", line 49, in <module>
File "build\\bdist.win32\\egg\\paramiko\\dsskey.py", line 26, in <module>
File "build\\bdist.win32\\egg\\Crypto\\PublicKey\\DSA.py", line 89, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\__init__.py", line 28, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\OSRNG\\__init__.py", line 34, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\OSRNG\\nt.py", line 28, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\OSRNG\\winrandom.py", line 7, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\OSRNG\\winrandom.py", line 4, in __bootstrap__
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1155, in resource_filename
self, resource_name
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1851, in get_resource_filename
self._extract_resource(manager, self._eager_to_zip(name))
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1881, in _extract_resource
self.egg_name, self._parts(zip_path)
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1221, in get_cache_path
self.extraction_error()
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1201, in extraction_error
raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg
cache:
[Error 5] Accesso negato: 'C:\\\\Windows\\\\Application Data'
The Python egg cache directory is currently set to:
C:\\Windows\\Application Data\\Python-Eggs
Perhaps your account does not have write access to this directory? You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.
Merci à l'avance
"Ne fonctionne pas" est une description de problème totalement inutile; vous devez obtenir un message d'erreur des journaux de votre serveur Web et le mettre dans la question pour permettre même un * début * à un bon diagnostic. –
ok, aucune idée sur la façon dont je peux enregistrer les erreurs? – z3d0
Cela dépend entièrement de votre serveur Web. Dans Apache, je m'attendrais à ce qu'ils soient déjà dans le error_log (en supposant une configuration par défaut raisonnable). –