Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Network Programming

You're reading from   Python Network Programming Conquer all your networking challenges with the powerful Python language

Arrow left icon
Product type Course
Published in Jan 2019
Publisher Packt
ISBN-13 9781788835466
Length 776 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Authors (4):
Arrow left icon
Dr. M. O. Faruque Sarker Dr. M. O. Faruque Sarker
Author Profile Icon Dr. M. O. Faruque Sarker
Dr. M. O. Faruque Sarker
Eric Chou Eric Chou
Author Profile Icon Eric Chou
Eric Chou
Abhishek Ratan Abhishek Ratan
Author Profile Icon Abhishek Ratan
Abhishek Ratan
Pradeeban Kathiravelu Pradeeban Kathiravelu
Author Profile Icon Pradeeban Kathiravelu
Pradeeban Kathiravelu
Arrow right icon
View More author details
Toc

Table of Contents (30) Chapters Close

Title Page
Copyright
About Packt
Contributors
Preface
1. Fundamental Concepts FREE CHAPTER 2. Python for Network Engineers 3. Continuous Integration for Network Engineers 4. SDN Concepts in Network Automation 5. Low-Level Network Device Interactions 6. APIs and Intent-Driven Networking 7. The Python Automation Framework – Ansible Basics 8. The Python Automation Framework – Beyond Basics 9. AWS Cloud Networking 10. Working with Git 11. Sockets, IPv4, and Simple Client/Server Programming 12. Multiplexing Socket I/O for Better Performance 13. IPv6, Unix Domain Sockets, and Network Interfaces 14. Programming with HTTP for the Internet 15. Email Protocols, FTP, and CGI Programming 16. Programming Across Machine Boundaries 17. Working with Web Services – SOAP, and REST 18. Network Monitoring and Security 19. Network Modeling 20. Authentication, Authorization, and Accounting (AAA) 21. Open and Proprietary Networking Solutions 22. NFV and Orchestration – A Larger Ecosystem 23. Programming the Internet 1. Other Books You May Enjoy Index

Listing the files in a remote FTP server


You would like to list the files available on the official Linux kernel's FTP site, ftp.kernel.org. You can select any other FTP site to try this recipe.

Getting ready

If you work on a production/enterprise FTP site with a user account, you need a username and password. However, in this instance, you don't need a username (and password) with the anonymous FTP server at the University of Edinburgh as you can log in anonymously.

How to do it...

We can use the ftplib library to fetch files from our selected FTP site. A detailed documentation of this library can be found at https://docs.python.org/3/library/ftplib.html for Python 3 and at http://docs.python.org/2/library/ftplib.html for Python 2.

ftplib is a built-in Python module, and you do not need to install it separately. Let us see how we can fetch some files with ftplib.

Listing 5.1 gives a simple FTP connection test as follows:

#!/usr/bin/env python 
# Python Network Programming Cookbook, Second Edition...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime