Getting a welcome message using getwelcome():

Once an initial connection is established, a server usually returns a welcome message. This message comes via the getwelcome() function, and sometimes includes disclaimers or helpful information that may be relevant to the user.

Now we will see an example of getwelcome(). Create a get_welcome_msg.py script and write the following content in it:

from ftplib import FTP

ftp = FTP('your-ftp-domain-or-ip')
ftp.login('your-username','your-password')

welcome_msg = ftp.getwelcome()
print(welcome_msg)

ftp.close()

Run the script as follows:

student@ubuntu:~/work$ python3 get_welcome_msg.py
220 (vsFTPd 3.0.3)

In the preceding code, we first mentioned the IP address, username, and password of the other machine. We used the getwelcome() function to get information after the initial connection was established.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset