Telnet versus telnetlib

Sean Davis seandavi at gmail.com
Fri Feb 29 17:34:41 EST 2008


I have used command-line telnet to login to a host, paste into the
window a small XML file, and then ^] to leave the window, and quit.
This results in a page (described by the XML file) being printed on a
printer.

When I do an analogous process using telnetlib, I get no debug output,
and most importantly, when I send the XML file to the host, I get no
printed page.  Unfortunately, I do not have access to the host to do
troubleshooting there, so I have to "feel" my way around.  Any
suggestions on what might be going wrong?

Thanks,
Sean

In [1]: import telnetlib

In [2]: tn=telnetlib.Telnet()

In [3]: tn.set_debuglevel(1)

In [4]: tn.open('labmatr',56423)

In [12]: tn.write("""<?xml version="1.0" encoding="UTF-8"?>
   ....: <labels _FORMAT="C:\labels\anzick_primary_sample.lbl"
_PRINTERNAME="Anzick1" _QUANTITY="1"
_JOBNAME="levineja_2_1198259890656">
   ....:     <label>
   ....:         <variable name="barcode">F3B85FCE-55CF-4541-80EB-
D1450377F7E0</variable>
   ....:         <variable name="Labmatrix_External_Barcode">BP10004
0701</variable>
   ....:     </label>
   ....: </labels>""")
Telnet(labmatr,56423): send '<?xml version="1.0" encoding="UTF-8"?>
\n<labels _FORMAT="C:\\labels\x07nzick_primary_sample.lbl"
_PRINTERNAME="Anzick1" _QUANTITY="1"
_JOBNAME="levineja_2_1198259890656">\n    <label>\n        <variable
name="barcode">F3B85FCE-55CF-4541-80EB-D1450377F7E0</variable>
\n        <variable name="Labmatrix_External_Barcode">BP10004 0701</
variable>\n    </label>\n</labels>'

In [13]: tn.write("\n")
Telnet(labmatr,56423): send '\n'

In [14]: tn.close()




More information about the Python-list mailing list