[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Telnet versus telnetlib

SeanDavis12

2/29/2008 10:35:00 PM

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

3 Answers

Gabriel Genellina

3/1/2008 6:44:00 AM

0

En Fri, 29 Feb 2008 20:34:41 -0200, Sean Davis <seandavi@gmail.com>
escribió:

> 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..."

--
Gabriel Genellina

Grant Edwards

3/2/2008 4:09:00 AM

0

On 2008-03-01, Gabriel Genellina <gagsl-py2@yahoo.com.ar> wrote:
> En Fri, 29 Feb 2008 20:34:41 -0200, Sean Davis <seandavi@gmail.com>
> escribió:
>
>> 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"

--
Grant Edwards grante Yow! You should all JUMP
at UP AND DOWN for TWO HOURS
visi.com while I decide on a NEW
CAREER!!

Gabriel Genellina

3/2/2008 8:48:00 AM

0

En Sun, 02 Mar 2008 02:09:14 -0200, Grant Edwards <grante@visi.com>
escribi�:

> On 2008-03-01, Gabriel Genellina <gagsl-py2@yahoo.com.ar> wrote:
>> En Fri, 29 Feb 2008 20:34:41 -0200, Sean Davis <seandavi@gmail.com>
>> escribió:
>>
>>> 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.

--
Gabriel Genellina