2017-08-04 16 views
-1

Pythonスクリプトを使用して、1か月に1回、FTPサーバーに2つのファイルをアップロードします。私はsleep(60*60*24)を使用して翌日を待っていますが、実際にファイルをアップロードする方法はわかりません。1日に1回FTPサーバーにファイルをアップロードするPythonスクリプト

私は約ftplibを知っていますが、私を助けたドキュメントは見つかりませんでした。

+0

:https://stackoverflow.com/questions/12613797/python-script-uploading-files-via-ftp –

答えて

1

この動作するはずのような何か:あなたはここで必要なものを見つけることが

#!/usr/bin/python 
import ftplib 
from time import sleep 

while True: 
    IP = "xx.xx.xx.xx" 
    path_file1 = "./MyFile1.py" 
    path_file2 = "./MyFile2.py" 

    UID = "" 
    PSW = "" 

    ftp = ftplib.FTP(IP) 
    ftp.login(UID, PSW) 
    ftp.cwd("/Unix/Folder/where/I/want/to/put/file") 

    with open(path_file1, 'r') as myfile: ftp.storlines('STOR ' + filename, myfile) 
    with open(path_file2, 'r') as myfile: ftp.storlines('STOR ' + filename, myfile) 

    sleep(86400) 
関連する問題