473,657 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending file to print server using ftplib

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\Zo peBBAp\Extensio ns\mk_zeb_label .py", line 38, in
mk_zeb_label
val=ftp.storlin es("STOR " + portname, file_handle)
File "C:\Python21\li b\ftplib.py", line 382, in storlines
conn = self.transfercm d(cmd)
File "C:\Python21\li b\ftplib.py", line 296, in transfercmd
return self.ntransferc md(cmd, rest)[0]
File "C:\Python21\li b\ftplib.py", line 273, in ntransfercmd
host, port = parse227(self.s endcmd('PASV'))
File "C:\Python21\li b\ftplib.py", line 229, in sendcmd
return self.getresp()
File "C:\Python21\li b\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=cSt ringIO.StringIO ()

printserver_ip= "192.168.2. 15"
portname="COM1"
zpt_code="""
^XA
^cfd,36,20
^by3,,50
^fo470,50
^abn,48,30^fdRE PAIR^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.wri te(zpt_code)
ftp=FTP(printse rver_ip)
ftp.login("","" )

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

return val
Jul 18 '05 #1
0 2118

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
12848
by: Limey Drink | last post by:
Hi all, Firstly :-) , is there any where I can search through archived newsgroup posts so I am not cluttering up the newsgroup with repeated queries ? And secondly :-), I know this has probably been discussed before but. I am wanting to do some scripting to automate a few administration tasks, one of the first tasks is automating FTP file transfers.
2
3546
by: Joshua Burvill | last post by:
Hello, I have the following script for printing something to a print server using ftplib, but it seems that I have a problem with putting the content into the file object as is shown by the following output from the script. Any tips? -Josh
5
12435
by: [ EuGeNe ] | last post by:
Hi all, I would like to write a script that downloads one file from a ftp server if the file creation date satisfy a condition. I can't figure out how to find from a ftp server what is the creation date of the file (using python). Any idea?
0
1825
by: Peter A. Schott | last post by:
Got a strange scenario going on here in that I could have sworn this worked yesterday. I am issuing binary retrieval calls to an FTP server, writing to a file, close the file, then removing the file from the remote site. When I do this, I end up with 0 byte files. I was hoping to avoid parsing a list of remote and local files and matching them up that way because it would be easier to remove on successful retrieve. I'm including some...
1
2490
by: Robert | last post by:
I just tried to convert a (hugh size) ftp.retrbinary run into a pseudo-file object with .read(bytes) method in order to not consume 500MB on a copy operation. First I thought, its easy as usual with python using something like 'yield' or so. Yet I didn't manage to do (without using threads or rewriting 'retrbinary')? Any ideas?
0
1120
by: Ahmed, Shakir | last post by:
HI Group, As I am very new in python field so this question might be very silly to you but if I get any help is highly appreciated. Problem: I wrote a python script which is working fine to upload files to the ftp server but the problem is it is reducing the actual size after transferring. I need to upload a GIS Shape file to the ftp server but
0
1434
by: Tarun Kapoor | last post by:
------- Code ------ remotepath = "/incoming" f = FTP(host) f.login(username,password) f.cwd(remotepath) localfile ="C:\\test.txt"
6
5772
by: half.italian | last post by:
Hi all, I'm using ftplib to transfer large files to remote sites. The process seems to work perfectly with small files, but when the file gets to large ~20GB I begin getting errors that sometimes seem to be non- fatal, and other times the transfer does not complete. I've debugged the hell out of the code, and can't figure out what is going on..is it the remote site? Packet loss? Traceback (most recent call last):
2
2166
by: skulka3 | last post by:
Hello, I want to implement file downloads inside an authenticated web page, such that when a user clicks a link, the server side python code connects to a ftp server, downloads a relevant file and then streams the file to the browser for the user to open it with the appropriate application. In this case it will either be a pdf or a tiff file. This function is quite similar to something like writing raw bytes to a ServletOutputStream...
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.