Telnet versus telnetlib

S

Sean Davis

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()
 
G

Gabriel Genellina

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?

In [12]: tn.write("""<?xml version="1.0" encoding="UTF-8"?>
....: <labels _FORMAT="C:\labels\anzick_primary_sample.lbl"

\ is the quote character. You have to duplicate it "C:\\labels..." or use
a raw string r"""<?xml ... _FORMAT="C:\labels..."
 
G

Grant Edwards

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?

In [12]: tn.write("""<?xml version="1.0" encoding="UTF-8"?>
....: <labels _FORMAT="C:\labels\anzick_primary_sample.lbl"

\ is the quote character. You have to duplicate it "C:\\labels..." or use
a raw string r"""<?xml ... _FORMAT="C:\labels..."

Or use a forward slash:

"C:/labels/anzick_primary_sample.lbl"
 
G

Gabriel Genellina

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?

In [12]: tn.write("""<?xml version="1.0" encoding="UTF-8"?>
....: <labels _FORMAT="C:\labels\anzick_primary_sample.lbl"

\ is the quote character. You have to duplicate it "C:\\labels..." or
use
a raw string r"""<?xml ... _FORMAT="C:\labels..."

Or use a forward slash:

"C:/labels/anzick_primary_sample.lbl"

I didn't menction that alternative because it generates a different
string; the resulting xml document may or may not be equivalent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,799
Latest member
Mercury_Dev

Latest Threads

Top