File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ File transfer protocol used to send and receive files using FTP server.
3+ Use credentials to provide access to the FTP client
4+
5+ Note: Do not use root username & password for security reasons
6+ Create a seperate user and provide access to a home directory of the user
7+ Use login id and password of the user created
8+ cwd here stands for current working directory
9+ """
10+
11+ from ftplib import FTP
12+ ftp = FTP ('xxx.xxx.x.x' ) """ Enter the ip address or the domain name here """
13+ ftp .login (user = 'username' , passwd = 'password' )
14+ ftp .cwd ('/Enter the directory here/' )
15+
16+ """
17+ The file which will be received via the FTP server
18+ Enter the location of the file where the file is received
19+ """
20+
21+ def ReceiveFile ():
22+ FileName = 'example.txt' """ Enter the location of the file """
23+ LocalFile = open (FileName , 'wb' )
24+ ftp .retrbinary ('RETR ' + filename , LocalFile .write , 1024 )
25+ ftp .quit ()
26+ LocalFile .close ()
27+
28+ """
29+ The file which will be sent via the FTP server
30+ The file send will be send to the current working directory
31+ """
32+
33+ def SendFile ():
34+ FileName = 'example.txt' """ Enter the name of the file """
35+ ftp .storbinary ('STOR ' + FileName , open (FileName , 'rb' ))
36+ ftp .quit ()
You can’t perform that action at this time.
0 commit comments