#!/usr/bin/python2.7
Serviceip12= ' 172.16.64.12 '
serviceip13= ' 172.16.64.13 '
User= ' Ebossapp '
Password12= ', Mb ([email protected] '
password13= ' 0mf[te]0 '
Remoutpath= '/ebossdata02/eboss/fileservice/bass/mms/'
Destdir= '/ebossdata02/eboss/fileservice/bass/bak/'
Import OS
Import Shutil
Import time
From Ftplib import FTP
#list local dir file name.
Listdir=os.listdir (Remoutpath)
#define CONNECT.
Def ftpconnect12 ():
Ftp=ftp ()
Ftp.connect (serviceip12,21)
Ftp.login (USER,PASSWORD12)
return FTP
Def ftpconnect13 ():
Ftp=ftp ()
Ftp.connect (serviceip13,21)
Ftp.login (USER,PASSWORD13)
return FTP
#Put file function.
Def putfile12 ():
FTP = ftpconnect12 ()
For LocalFile in Listdir:
BufSize = 4096
File_handle=open (Remoutpath+localfile, "rb+")
Ftp.storbinary (' STOR ' +remoutpath+localfile,file_handle,bufsize)
File_handle.flush ()
Ftp.close ()
Def putfile13 ():
FTP = ftpconnect13 ()
For LocalFile in Listdir:
BufSize = 4096
File_handle=open (Remoutpath+localfile, "rb+")
Ftp.storbinary (' STOR ' +remoutpath+localfile,file_handle,bufsize)
File_handle.flush ()
Ftp.close ()
#Clean file
Def cleanfile ():
For LocalFile in Listdir:
Fpath,fname=os.path.split (LocalFile)
Shutil.move (Remoutpath+localfile,destdir+fname)
If __name__== "__main__":
Putfile12 ()
If __name__== "__main__":
Putfile13 ()
If __name__== "__main__":
Cleanfile ()
Python for FTP uploads