On 14 September 2011 20:44, James Hartley <[email protected]> wrote:
> #!/usr/bin/env python
>
> import telnetlib
>
> if __name__ == '__main__':
> print 'begin'
> tn = telnetlib.Telnet('gmail-smtp-in.l.google.com', 25)
> s = tn.read_very_eager()
> print s
> tn.write("helo\n")
> s = tn.read_very_eager()
> print s
> tn.write("quit\n")
> s = tn.read_very_eager()
> print s
> print 'end'
> $ python script.py
> begin
>
>
>
> end
> $
>
> What do I need to do to emulate the IDE environment? If I am needing to
> capture stdout, it isn't readily apparent.
>
Make it go slower or force it to read *some* data at least. Interactively
there's plenty of time for data to arrive for read_very_eager() to read.
When run as a batch your computer tries to read and continue before any
data's been returned from google.
Hence, try using read_some() instead of read_very_eager().
Aside: If you want to interact with a mail server there's probably better
modules to be using than the telnet module.
Walter
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor