Sending file to print server using ftplib

Discussion in 'Python' started by Joshua Burvill, May 20, 2004.

  1. 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
     
    Joshua Burvill, May 20, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Williams
    Replies:
    0
    Views:
    2,858
    Tim Williams
    Oct 20, 2004
  2. Peter A. Schott
    Replies:
    0
    Views:
    403
    Peter A. Schott
    Feb 1, 2005
  3. Peter A. Schott
    Replies:
    0
    Views:
    923
    Peter A. Schott
    Feb 10, 2005
  4. alex
    Replies:
    3
    Views:
    464
  5. keto
    Replies:
    0
    Views:
    1,043
Loading...

Share This Page