Sending file to print server using ftplib

J

Joshua Burvill

Hello,

I am trying to print something to a print server using the following
function
but I get errors, does anyone have any pointers?

Rgds, Josh

Traceback (most recent call last):
File "<pyshell#2>", line 1, in ?
mk_zeb_label()
File "\\mrisydney\ZopeBBAp\Extensions\mk_zeb_label.py", line 38, in
mk_zeb_label
val=ftp.storlines("STOR " + portname, file_handle)
File "C:\Python21\lib\ftplib.py", line 382, in storlines
conn = self.transfercmd(cmd)
File "C:\Python21\lib\ftplib.py", line 296, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Python21\lib\ftplib.py", line 273, in ntransfercmd
host, port = parse227(self.sendcmd('PASV'))
File "C:\Python21\lib\ftplib.py", line 229, in sendcmd
return self.getresp()
File "C:\Python21\lib\ftplib.py", line 202, in getresp
raise error_perm, resp
error_perm: 501 command not supported.

########################
## SCRIPT STARTS HERE ##
########################

def mk_zeb_label():

from ftplib import FTP
import string, cStringIO




## Create file-handle to a "file-like" string
file_handle=cStringIO.StringIO()

printserver_ip="192.168.2.15"
portname="COM1"
zpt_code="""
^XA
^cfd,36,20
^by3,,50
^fo470,50
^abn,48,30^fdREPAIR^fs
^fo50,150
^fdSome text goes here.^fs
^fdSome text goes here.^fs
^fdSome text goes here.^fs
^fo50,50
^bc^fd114567^fs
^XZ
"""


file_handle.write(zpt_code)
ftp=FTP(printserver_ip)
ftp.login("","")

val=ftp.storlines("STOR " + portname, file_handle)

return val
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top