Download presentation
Presentation is loading. Please wait.
Published byDulcie James Modified over 8 years ago
1
FTPLIB Dick Steflik CS360
2
FTPLIB a Python module to allow the user to transfer files between a user program and an FTP Server. The user should understand the command line version of FTP that comes with the application suite for all common TCP/IP stacks – See the FTP notes on the CS328 web site at: http://www.binghamton.edu/~steflik/cs328/cs328.htm
3
Constructors FTP ([host[,user[,passwd[,acct[,timeout]]]]]) returns a new instance of the FTP client class, this is for connecting to unsecure FTP servers. FTP_TLS ([host[,user[,passwd[,acct[, keyfile[,certfile[,timeout]]]]]]]) returns a new instance of the FTP_TLS class, this is for connecting to secure FTP servers.
4
Methods set_debuglevel – controls the amount of output. (0-none, 1-moderate, 2 0r higher – maximum amount) connect([host[, port[,timeout]]]) - default port is 21, the timeout (unless specified) is the global timeout This method must be done before an other methods can be invoked. getwelcome() - get the remote host’s welcome message. login([user[,passwd[,acct]]]) – user and passwd are strings; can be left as null strings if site is anonymous. Most commands are allowed only after logging in. The acct parameter is seldom used and is optional. abort() – Abort an in progress file transfer. sendcmd(command) – send a command string to the server and return the response. voidcmd (command) – send a simple command to the server and handle the response. retrlines(command[,callback]) Retrieve a file or directory list in ASCII transfer mode. Command should be LIST, NLST. Callback is called for each line (default callback is to print the line to sys.stdout)
5
Methods (more) set_pasv (boolean) – Enable passive mode (true = on, false = off) storlines(command, file[, callback]) – Store a file in ASCII transfer mode. Lines are read from file until EOF. Callback is call after each line is sent. nlst(argument[,,,,,]) - Return a list of file names in the remote directory. dir(argument[,,,,,,]) – Return a directory list of the remote directory. last argument can be the name of a callback. rename(fromname, toname) – rename the remote file from fromname to toname. delete(filename) – delete filename from the server, is successful returns a normal respone, if unsuccessful raises error_perm or error_reply. cwd(pathname) – set the current directory on the server mkd(dirname) - create a new directory in the server’s current directory pwd() – Return the pathname of the current working directory on the server. rmd(dirname) – remove directory dirname from the server.
6
Methods (more) size(filename) – Request the size of the file on the server. quit() – Send a QUIT command to the server to close the connection. close() – Unilaterally clost the connection to the server.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.