January 2019
Beginner
318 pages
8h 23m
English
In this section, we are going to learn about the sendcmd() function. We can use the sendcmd() function to send a simple string command to the server to get the String response. The client can send FTP commands such as STAT, PWD, RETR, and STOR. The ftplib module has multiple methods that can wrap these commands. The commands can be sent using the sendcmd() or voidcmd() methods. As an example, we are going to send a STAT command to check the status of a server.
Create a send_command.py script and write the following content in it:
from ftplib import FTPftp = FTP('your-ftp-domain-or-ip')ftp.login('your-username','your-password')ftp.cwd('/home/student/')s_cmd_stat = ftp.sendcmd('STAT') ...Read now
Unlock full access