FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 6th, 2004, 09:56 PM
SolarBear's Avatar
SolarBear SolarBear is offline
onCsdfeu
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Canada
Posts: 100 SolarBear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 7 m 43 sec
Reputation Power: 6
Send a message via ICQ to SolarBear Send a message via MSN to SolarBear
File transfer over FTP

I've written the following script to automate my tutorial updates:
Code:
#SolarBear's script of tutorial sending

import ftplib,os

filepath = 'F:\Documents and Settings\David\Mes documents\py\\'
filename = 'python_tutorial_by_SolarBear.pdf'
f = open(filename,'r')
rootr = ftplib.FTP('rootr.com','username','password')

rootr.set_debuglevel(2) #just in case
rootr.cwd('web/solarbear.rootr.com')
try:
    rootr.delete(filename)
except: pass
rootr.storbinary('STOR '+ filename,f)
rootr.quit()
f.close()

Connecting and file deletion (is it even necessary ?) work ok, the problem is in the file-sending part : after being 'sent'. I end up with a 3 kb file while it should be around 300 kb. Clearly, only a small portion of the file gets sent.

My guess is that the connection closes too fast to leave enough time for the file to be sent... How can I make so the file actually gets sent ?
__________________
Time is the greatest of teachers ; sadly, it kills all of its students.
- Hector Berlioz

Reply With Quote
  #2  
Old February 7th, 2004, 12:38 AM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
Well, you set the filepath but you never prepend it to the filename ... looks to me like you should be getting an IOError for the file not existing unless you have a copy in the current directory. Nothing else looks incorrect, the storbinary method should block until it's done, I believe. I think it would also raise an exception if it didn't complete successfully.

Reply With Quote
  #3  
Old February 10th, 2004, 10:07 AM
SolarBear's Avatar
SolarBear SolarBear is offline
onCsdfeu
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Canada
Posts: 100 SolarBear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 7 m 43 sec
Reputation Power: 6
Send a message via ICQ to SolarBear Send a message via MSN to SolarBear
Ok, just a FYI, just in case. After asking around, I finally got to change the following line:
Code:
f = open(filename,'rb')

And by opening it as binary, everything goes well and good.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > File transfer over FTP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway