I would like to make a script to upload a file to FTP.
How would the login system work? I'm looking for something like this:
ftp.login=(mylogin)
ftp.pass=(mypass)
And any other sign in credentials.
I would like to make a script to upload a file to FTP.
How would the login system work? I'm looking for something like this:
ftp.login=(mylogin)
ftp.pass=(mypass)
And any other sign in credentials.
You will most likely want to use the ftplib module for python
This logs you into an FTP server. What you do from there is up to you. Your question doesnt indicate any other operations that really need doing.
Use
ftplib
, you can write it like this:Use
ftplib.FTP_TLS
instead if you FTP host requires TLS.To retrieve it, you can use
urllib.retrieve
:EDIT:
To find out the current directory, use
FTP.pwd()
:To change the directory, use
FTP.cwd(pathname)
:I just answered a similar question here IMHO, if your FTP server is able to communicate with Fabric please us Fabric. It is far better than doing raw
ftp
.I have an FTP account from
dotgeek.com
so I am not sure if this will work for other FTP accounts.save the file as
fabfile.py
and runfab copy
locally.Once again, if you don't want to input password all the time, just add
Try this:
You can use the below function. I haven't tested it yet, but it should work fine. Remember the destination is a directory path where as source is complete file path.