LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-06-2013, 11:36 PM   #1
0men
Member
 
Registered: Mar 2011
Location: Brisbane
Distribution: Windows 10, Red Hat, Debian
Posts: 183

Rep: Reputation: 22
Python simple upload to FTP server.


Hey guys, hope someone can help with this as i've run out of resources. Just trying to upload a simple .txt script to a FTP server. This is what i've come down to...

Code:
from ftplib import FTP

fo=open("foo.txt", "wb")
fo.write("hello world")
fo.close()

FTP=FTP('ftp.ftpsite.com')
FTP.login(user='0men', passwd='password123')

FTP.storlines("STOR, foo.txt", "f")
FTP.quit()
FTP.close()
I've chopped and changed this code around, but still cant get anything, apart from errors, such as this..

Code:
line 14, in <module>
    FTP.storlines("STOR, foo.txt", "f")
  File "C:\Python27\lib\ftplib.py", line 483, in storlines
    conn = self.transfercmd(cmd)
  File "C:\Python27\lib\ftplib.py", line 368, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python27\lib\ftplib.py", line 331, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "C:\Python27\lib\ftplib.py", line 244, in sendcmd
    return self.getresp()
  File "C:\Python27\lib\ftplib.py", line 219, in getresp
    raise error_perm, resp
error_perm: 501 Syntax error: Command not understood.
Thanks in advance, hoping someone can help.
 
Old 02-07-2013, 12:12 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
I don't see an open file handle ...


Quote:
FTP.storlines(command, file[, callback])

Store a file in ASCII transfer mode. command should be an appropriate STOR command (see storbinary()). Lines are read until EOF from the open file object file using its readline() method to provide the data to be stored. callback is an optional single parameter callable that is called on each line after it is sent.

Changed in version 2.6: callback parameter added.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FTP server file is not upload jitenderana Linux - Networking 9 09-30-2011 06:44 AM
Need to upload data into the ftp server siddhant_2010 Linux - Server 2 04-01-2010 11:38 PM
ftp server with upload permission Gero Linux - Networking 0 11-19-2004 03:38 AM
Can login to WU-FTP server but cannot upload friddick Linux - Networking 0 08-21-2003 09:00 AM
Can login to WU-FTP server but cannot upload friddick Linux - Networking 0 08-21-2003 09:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration