need help running python script in linux

xunil collin_sq2003 at yahoo.com
Mon May 17 04:02:17 EDT 2004


hi, could any one please help show me how to run a python script in
linux ?

when i try "python script.py" it just does nothing 

this is the script iam trying to run 


#!/usr/bin/env python
"USAGE: echoserver.py <port>"
from SocketServer import BaseRequestHandler, TCPServer
import sys, socket

class EchoHandler(BaseRequestHandler):
    def handle(self):
        print "Client connected:", self.client_address
        self.request.sendall(self.request.recv(2**16))
        self.request.close()
        
        if len(sys.argv) != 2:
            print __doc__
        else:
            TCPServer(('',int(sys.argv[1])),
EchoHandler).serve_forever()
          

this is code for a server socket , iam supposed to see some messages
when i run the script but nothing shows completely

even the client script reacts the same way 
below is the client code 

#!/usr/bin/env python
"USAGE: echoclient.py <server> <word> <port>"
from socket import *    # import *, but we'll avoid name conflict
import sys
if len(sys.argv) != 4:
    print __doc__
    sys.exit(0)
    sock = socket(AF_INET, SOCK_STREAM)
    sock.connect((sys.argv[1], int(sys.argv[3])))
    message = sys.argv[2]
    messlen, received = sock.send(message), 0
    if messlen != len(message):
        print "Failed to send complete message"
        print "Received: ",
        while received < messlen:
            data = sock.recv(32)
            sys.stdout.write(data)
        received += len(data)
        print
        sock.close()


i have the python interpreter installed already 
but i don't know why these failed to run.

could some one please come to my rescue



More information about the Python-list mailing list