[Tutor] Telnet Programme Question

Ali Polatel alipolatel at yahoo.com
Sun Aug 15 18:21:35 CEST 2004


Friends,
My telnet programme is going well :)
Now I can connect to the server and type-in login name and password easily....
Now I have a more complicated problem
The command prompt of the server is 'fics%'
First let me show you the script so that you'll understand better :
"#!usr/bin/python
import telnetlib
from sys import exit
from time import sleep
# PLAY CHESS IN FICS via Telnet!(without timeseal!)
a=telnetlib.Telnet(host='64.71.131.140',port='5000')
a.read_until('login:')
b=str('username'+chr(10))
a.write(b)
b=str('passwordl'+chr(10))
a.read_until('password:')
a.write(b)
print a.read_until('fics%')

Until here programme works ok
Now I want it to look if there is something in the server(like tells,channel tells etc.)
and print if there is any or wait if there is nothing...
Also it should be able to get the commands that I type from me meanwhile
So I have written the things below but it doesn't work
x=0
c=raw_input()
while x<999999999:
        if  a.read_until('fics%',timeout=1)<>' ' and  c==' ' :
            print a.read_until('fics%',timeout=1)
            sleep(1)
        else:
            a.write(str(c)+chr(10))
            print a.read_until('fics%',timeout=1)
            c=''
            c=raw_input()
            sleep(1)
        x=x+1
 
but if I accept no commands(raw-input) s from the user it works perfect.
eg:
..."while x<999999999:
        if  a.read_until('fics%',timeout=1)<>' '
        print a.read_until('fics%',timeout=1)
        sleep(1)
        else:" and so on
So what I need is to make the programme wait 1 second for a raw-input and if there is no raw input it should continue his work...
Anyone who can solve this?
Regards,
Ali Polatel

		
---------------------------------
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040815/d5bfa1aa/attachment.htm


More information about the Tutor mailing list