Book Image

Mastering Python Scripting for System Administrators

By : Ganesh Sanjiv Naik
Book Image

Mastering Python Scripting for System Administrators

By: Ganesh Sanjiv Naik

Overview of this book

Python has evolved over time and extended its features in relation to every possible IT operation. Python is simple to learn, yet has powerful libraries that can be used to build powerful Python scripts for solving real-world problems and automating administrators' routine activities. The objective of this book is to walk through a series of projects that will teach readers Python scripting with each project. This book will initially cover Python installation and quickly revise basic to advanced programming fundamentals. The book will then focus on the development process as a whole, from setup to planning to building different tools. It will include IT administrators' routine activities (text processing, regular expressions, file archiving, and encryption), network administration (socket programming, email handling, the remote controlling of devices using telnet/ssh, and protocols such as SNMP/DHCP), building graphical user interface, working with websites (Apache log file processing, SOAP and REST APIs communication, and web scraping), and database administration (MySQL and similar database data administration, data analytics, and reporting). By the end of this book, you will be able to use the latest features of Python and be able to build powerful tools that will solve challenging, real-world tasks
Table of Contents (21 chapters)

To get the most out of this book

We wrote this book to be as accessible as possible and to teach you many different approaches to programming with Python through several scripts. However, to get the most out of them, you need to do the following:

  • Have a Linux system set up and configured for testing/debugging scripts
  • Understand the created scripts
  • Keep in mind what the components of each script are
  • Check how the components could be reused or combined in new ways

This book assumes a certain level of Python knowledge to begin your journey; these basic skills will not be covered in this book. These skills include the following:

  • How to set up and configure a Linux system
  • How to install, access, and configure a specific Python IDE (although several are
    already included in most Linux distributions)
  • Some basics about computing and programming (although we will do our best to
    provide a crash course)

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub https://github.com/PacktPublishing/Mastering-Python-Scripting-for-System-Administrators-/. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: " To unpack the archives shutil module has unpack_archive() function."

A block of code is set as follows:

 >>> 3 * 'hi' + 'hello'
'hihihihello'

Any command-line input or output is written as follows:

  sudo apt install python3-pip

Bold: Indicates a new term, an important word, or words that you see onscreen. Here is an example: " The CSV format, which stands for Comma Separated Values format."

Warnings or important notes appear like this.
Tips and tricks appear like this.