By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,171 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,171 IT Pros & Developers. It's quick & easy.

Sending file to print server using ftplib

P: n/a
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
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.