[Tutor] Problem to recognize string
W X Liu
csmwxl at bath.ac.uk
Tue Sep 21 00:56:06 CEST 2004
Hi all,
I am writing a piece of program to interact with telnet, here is the program
import telnetlib
import sys
a=telnetlib.Telnet(host='mudlib.anarres.org',port='5000')
a.read_until('Anarres II login:')
b=str('acb'+chr(5))
a.write(b+ "\n")
b=str('y'+chr(2))
a.write(b+ "\n")
b=str('spam hi'+chr(15))
a.write(b+ "\n")
if a.read_until('hi'):
b=str('spam hello')
a.write(b+ "\n")
print a.read_all()
The question is that I want to wait for somebody to say 'hi' to this program
instead of program itself. So it cannot recognize who said 'hi', everytime I
run it, it will print doubly the 'hi', in fact I want this progran say hi and
somebody replies it with saying 'hi', then program say hello.
So anyone can help me to solve this problem?
Wenxin
More information about the Tutor
mailing list