[Tutor] Capturing and parsing over telnet

David david at abbottdavid.com
Sun Nov 30 10:26:42 CET 2008


Stephen Nelson-Smith wrote:
> I want to write a program that connects to a TCP port using telnet,
> and issues commands, parsing the output the command provides, and then
> issuing another command.
> 
> This might look like this:
> 
> $ telnet water.fieldphone.net 7456
> Welcome to water, enter your username
>> _ sheep
> Enter your password
>> _ sheep123
>> _ examine here
> [some info to parse]
> [.]
> [.]
>> _ some command based on parsing the previous screen
> [more info to parse]
> [.]
> [.]
> 
> I am confident I can parse the info, if I can read it in.
> 
> I am not sure how to handle the telnet I/O
> 
> How should I proceed?
> 
> S.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
How about pexpect;
http://www.noah.org/wiki/Pexpect

-- 
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com



More information about the Tutor mailing list