Getwelcome() Method Of FTP Class In Python

Method Name:

getwelcome

Method Signature:

getwelcome()

Return Value:

A Python string containing the welcome message sent by the FTP server.

Parameters:

None.

Overview:

  • When the connection is established with the FTP server, a 220 message is sent to the client. This message could be long containing greetings, welcome message or policies that are to be adhered.
  • The getwelcome() method returns this message. The same message is returned by the connect() method as well.

Example:

from ftplib import FTP

 

hostName = "publicftpserverthatallowstesting.com";

 

# Create an FTP instance

ftpObject = FTP("");

 

ftpResponse = ftpObject.connect("hostName");

ftpResponse = ftpObject.login(user="demo", passwd="password");

 

# Get the welcome message from server

welcomeMessage = ftpObject.getwelcome();

 

# This message is the same as the value of the ftpResponse variable

# after the connect method

print(welcomeMessage);

 

 

Output:

220 Connection successful to the hypothetical  publicftpserverthatallowstesting.com. Welcome!

 


Copyright 2022 © pythontic.com