473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Does FTPLIB have a 'local change directory' ?

Hi, first I wanted to say that:

I have finally been able to ftp a file in my python app - however, it
works like this:

When you use storbinary and hand it a full path
"c:\myfiles\morefiles\picture.gif"..
it will find the file on your hard drive, and
then upload the file, but on the ftp server, it literally names the file:

"c:\myfiles\morefiles\picture.gif"
I'd like to be able to first

ftplib.lcd( "c:\myfiles\morefiles" )

and then just

storbinary( picture.gif .. ).

But the python doc doesn't show any LCD.

Or am I going to have to be satisfied with having to just use a rename on
the server,
after uploading the file?

Thanks
Steve


Aug 7 '05 #1
4 6487
python newbie wrote:
Hi, first I wanted to say that:

I have finally been able to ftp a file in my python app - however, it
works like this:

When you use storbinary and hand it a full path
"c:\myfiles\morefiles\picture.gif"..
it will find the file on your hard drive, and
then upload the file, but on the ftp server, it literally names the file:

"c:\myfiles\morefiles\picture.gif"
I'd like to be able to first

ftplib.lcd( "c:\myfiles\morefiles" )

and then just

storbinary( picture.gif .. ).

But the python doc doesn't show any LCD.


os.chdir()

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Aug 7 '05 #2
If you want to change the working directory of a Python program, then use
os.chdir() for that purpose. That's what 'lcd' does in ftp client software.
It doesn't send a remote command of any kind.

Or, when you call the storbinary method, give the os.path.basename() of the
file you are storing, instead of the name you used to open the file on the local
system.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFC9WZgJd01MZaTXX0RAg6UAKCSztXi8VVC9PvkKprv5Q wBctMDHwCgqSho
A7t6OLeHZBp/uXybH5wWXK4=
=5XcD
-----END PGP SIGNATURE-----

Aug 7 '05 #3
On Sun, 07 Aug 2005 01:28:31 GMT,
"python newbie" <qu**************@gmail.com> wrote:
I'd like to be able to first ftplib.lcd( "c:\myfiles\morefiles" ) and then just storbinary( picture.gif .. ). But the python doc doesn't show any LCD.


Try os.chdir.

HTH,
Dan

--
Dan Sommers
<http://www.tombstonezero.net/dan/>
Aug 7 '05 #4
Yes, I tried using just the filename itself in using storbinary, but
it returned some kind of error, but your suggestion to use os.chdir is
so obvious I'm not sure why I didn't think of that.
Thanks for the email
Steve

On 8/6/05, je****@unpythonic.net <je****@unpythonic.net> wrote:
If you want to change the working directory of a Python program, then use
os.chdir() for that purpose. That's what 'lcd' does in ftp client software.
It doesn't send a remote command of any kind.

Or, when you call the storbinary method, give the os.path.basename() of the
file you are storing, instead of the name you used to open the file on the local
system.

Jeff


Aug 7 '05 #5

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

Similar topics

2
by: Stephen Horne | last post by:
Just recently I decided I want to make use of my ISP freebie webspace. In order to make that easier, I'd like to be able to automatically synchronise an FTP file/folder heirarchy with one on my...
1
by: John fabiani | last post by:
Hi, I have a script that is not running on a freeBSD 4.4 with Python 2.1 that uses ftplib. I'm wondering if it's possible to update only the ftplib module from 2.1 to 2.3. I only ask because I...
5
by: Richard Lewis | last post by:
Hi there, I'm having a problem with unicode files and ftplib (using Python 2.3.5). I've got this code: xml_source = codecs.open("foo.xml", 'w+b', "utf8") #xml_source = file("foo.xml",...
0
by: Nico Grubert | last post by:
Hi there, I am using the ftplib library to connect to a ftp server. After I got connected, I can see a list of file in the current directory using ftp.dir() or ftp.retrlines('LIST'). But using...
2
by: Harlin Seritt | last post by:
Using ftplib from Python I am trying to get all files in a particular directory using ftplib and then send those same files to another ftp server. I have tried using commands like 'get *' and 'mget...
1
by: eight02645999 | last post by:
hi my purpose is just to connect to an FTP server and delete all files in a directory Is there a way using ftplib module? something like ftp.delete("*") ? another way i can do is using LIST to...
3
by: blancmunier1 | last post by:
Hello dear community ! I'm a bit ashamed to ask such an easy question, but I didn't find my answer on previous posts. I'd like to copy files with FTP protocol in a subdirectory. So far, my code...
1
by: Merrigan | last post by:
Hi All, I have written a little script to upload some files to an ftp folder. The problem is as follows : I wrote the script on my windows laptop, and I want to run it from mylinux server....
1
by: loial | last post by:
Trying to use ftplib.FTP.nlst() method to list the files in a directory on a FTP server. It works fine except when there are no files in the directory. Then it gives the error ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.