Bonjour, je débute sous linux ( Ubuntu )
J'ai fait un programme:
[code:1:c17641126e]#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import socket
host, port = 'www.commentcamarche.net', 80
sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
query = 'GET /histoires/pirate.php3 HTTP/1.1\r\n'
query += 'Host: www.commentcamarche.net\r\n'
query += 'Connexion: close\r\n\r\n'
sock.connect((host,port))
sock.send(query)
reponse = sock.recv(2048)
print (reponse)[/code:1:c17641126e]
Enregitré sous test.py dans le dossier /home/paolo
Ensuite dans le Shell je lance python :
[code:1:c17641126e]
paolo@Paolo_Laptop:~$python
Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[/code:1:c17641126e]
ensuite je lance le fichier test.py :
[code:1:c17641126e] >>> test.py [/code:1:c17641126e]
Et là ça me met :
[code:1:c17641126e]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'test' is not defined
[/code:1:c17641126e]
Donc la je sais pas ou est le problème .....