473,378 Members | 1,405 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,378 software developers and data experts.

ftplib

I want to upload a file to my server, I understand I should use the storlines() method, but I don't understand what cmd should be.

and fp would be the file object I want to upload, correct?
Apr 12 '07 #1
4 2766
bartonc
6,596 Expert 4TB
I want to upload a file to my server, I understand I should use the storlines() method, but I don't understand what cmd should be.

and fp would be the file object I want to upload, correct?
Here are Basic FTP Commands to get you going.
Apr 12 '07 #2
According to that page the command I would need would be 'put', I tried that but got this:

Traceback (most recent call last):
File "C:/Documents and Settings/William/Desktop/ftp.py", line 6, in <module>
ftp.storlines('put', open('C:/config/quotes/website/index.html', 'r'))
File "C:\Python25\lib\ftplib.py", line 426, in storlines
conn = self.transfercmd(cmd)
File "C:\Python25\lib\ftplib.py", line 345, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Python25\lib\ftplib.py", line 327, in ntransfercmd
resp = self.sendcmd(cmd)
File "C:\Python25\lib\ftplib.py", line 241, in sendcmd
return self.getresp()
File "C:\Python25\lib\ftplib.py", line 216, in getresp
raise error_perm, resp
error_perm: 500 Unknown command
Apr 12 '07 #3
ghostdog74
511 Expert 256MB
typical put eg:
Expand|Select|Wrap|Line Numbers
  1. from ftplib import FTP
  2. import sys, getpass, os.path
  3. host, username, localfile, remotepath = sys.argv[1:]
  4. password = getpass.getpass("Enter password for %s on %s: " % \
  5.         (username, host))
  6. f = FTP(host)
  7. f.login(username, password)
  8.  
  9. f.cwd(remotepath)
  10. fd = open(localfile, 'rb')
  11. f.storbinary('STOR %s' % os.path.basename(localfile), fd)
  12. fd.close()
  13.  
  14. f.quit()
  15.  
Apr 12 '07 #4
Thank you.
Apr 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of...
0
by: Joshua Burvill | last post by:
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...
2
by: siggy2 | last post by:
Hi, I'm using Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32 I've noticed a strange (= not deterministic) behaviour of ftplib.py: sometimes (not always) it fails (after a variable number of...
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: Jon Bowlas | last post by:
Hi All, I've written a little method to connect to an ftpserver which works well, however when I send a file using this ftp connection oddly I _sometimes_ get returned an EOFError from...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.