Warning: Use of undefined constant headerfavicons - assumed 'headerfavicons' (this will throw an Error in a future version of PHP) in /home/thetoryp/www/www/wp-content/plugins/easy-favicon/easy-favicon.php on line 6231

Warning: Use of undefined constant headerfavicons - assumed 'headerfavicons' (this will throw an Error in a future version of PHP) in /home/thetoryp/www/www/wp-content/plugins/easy-favicon/easy-favicon.php on line 6279

Warning: Use of undefined constant headerfavicons - assumed 'headerfavicons' (this will throw an Error in a future version of PHP) in /home/thetoryp/www/www/wp-content/plugins/easy-favicon/easy-favicon.php on line 6327
telnetlib Archives - The Tory Party Skip to content

Telnetlib not reading all output? Try asynchat

Telnetlib not reading all output? Try asynchat published on

Telnetlib not reading all output? Not receiving all the output from your telnetlib session? read_until() not an option because you don’t know what output to look for? telnetlib not queueing your writes?

Think you want a telnetlib alternative, but Google isn’t turning anything up?

I’ve been there.

Headbanging Gods of Metal Traveller
There was head-banging, but it was not a ball
Image stolen from Metal Traveller

After a couple of days of madness I learned a few things:

– In Maya at least, not all output generated by the server is available to be read. I can call print("foo") all day and never read back “foo” on the client. Apparently it is known that “python print does not appear in certain output”. I ended up using the mel warning command, and if you think that sounds like overkill you are probably right.

– After much much much Googling, this stackoverflow answer pointed me to asynchat. I ended up writing a tiny client by extending asynchat, and Turns out I didn’t want a telnetlib alternative; I wanted a module that did much less!

not a python but still happy
Not a python but still happy

telnetlib doesn’t seem to queue writes. You can send two writes in a row, but there’s no guarantee the second one will be received by the server. Troublesome if you’re trying to use a second write as a way to determine when the first write has finished executing. Fortunately asynchat.push() works like a boss.

– More information and a code sample can be found at stackoverflow. I have personal insight on a code problem about once in a bazillion years, so this is very exciting to me.

If this post helps one person headbang only by choice, I have succeeded.

Primary Sidebar