Mastering Python Scripting for System Administrators
eBook - ePub

Mastering Python Scripting for System Administrators

Write scripts and automate them for real-world administration tasks using Python

Ganesh Naik

Compartir libro
  1. 318 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Mastering Python Scripting for System Administrators

Write scripts and automate them for real-world administration tasks using Python

Ganesh Naik

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

Leverage the features and libraries of Python to administrate your environment efficiently.

Key Features

  • Learn how to solve problems of system administrators and automate routine activities
  • Learn to handle regular expressions, network administration
  • Building GUI, web-scraping and database administration including data analytics

Book Description

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

What you will learn

  • Understand how to install Python and debug Python scripts
  • Understand and write scripts for automating testing and routine administrative activities
  • Understand how to write scripts for text processing, encryption, decryption, and archiving
  • Handle files, such as pdf, excel, csv, and txt files, and generate reports
  • Write scripts for remote network administration, including handling emails
  • Build interactive tools using a graphical user interface
  • Handle Apache log files, SOAP and REST APIs communication
  • Automate database administration and perform statistical analysis

Who this book is for

This book would be ideal for users with some basic understanding of Python programming and who are interested in scaling their programming skills to command line scripting and system administration.

Prior knowledge of Python would be necessary.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Mastering Python Scripting for System Administrators un PDF/ePUB en línea?
Sí, puedes acceder a Mastering Python Scripting for System Administrators de Ganesh Naik en formato PDF o ePUB, así como a otros libros populares de Computer Science y System Administration. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2019
ISBN
9781789134261
Edición
1

Python Scripting Overview

Python is a scripting language, created by Guido van Rossum in 1991, which is used in various applications, such as game development, GIS programming, software development, web development, data analytics, machine learning, and system scripting.
Python is an object-oriented, high-level programming language with dynamic semantics. Mainly, Python is an interpreted language. Python is used for rapid application development, as it has all of the advanced features for development.
Python is simple and easy to learn, as its syntax makes programs more readable. Hence, the program maintenance cost is low.
Python has one more important feature of importing modules and packages. This feature allows for code reuse. The Python interpreter is easy to understand. We can write the complete code one by one in it and, as Python is an interpreted language, the code gets executed line by line. Python also has a wide range of libraries for advanced functionality.
This chapter will cover the following topics:
  • Python scripting
  • Installing and using Python and various tools
  • Variables, numbers, and strings
  • Python supported data structures and how to use all of these concepts in a script
  • Decision making; that is, the if statement
  • Looping statements; that is, the for and while loops
  • Functions
  • Modules

Technical requirements

Before you start reading this book, you should know the basics of Python programming, such as the basic syntax, variable types, tuple data type, list dictionary, functions, strings, and methods. Two versions, 3.7.2 and 2.7.15, are available at python.org/downloads/. In this book we'll work with version 3.7 for code examples and package installing.
Examples and source code for this chapter are available in the GitHub repository: https://github.com/PacktPublishing/Mastering-Python-Scripting-for-System-Administrators-.

Why Python?

Python has a wide range of libraries for open source data analysis tools, web frameworks, testing, and so on. Python is a programming language that can be used on different platforms (Windows, Mac, Linux, and embedded Linux H/W platforms, such as Raspberry Pi). It's used to develop desktop as well as web applications.
Developers can write programs with fewer lines if they use Python. Prototyping is very quick, as Python runs on an interpreter system. Python can be treated in an object-oriented, a procedural, or a functional way.
Python can do various tasks, such as creating web applications. It is used with the software to create workflows; it connects to database systems, handles files, handles big data, and performs complex mathematics.

Python syntax compared to other programming languages

The code written in Python is highly readable because it's similar to the English language. To complete a command, Python uses new lines.
Python has a great feature: indentation. Using indentations, we can define the scope for decision-making statements, loops such as for and while loops, functions, and classes.

Python installation

In this section, we will be learning about the installation of Python on different platforms, such as Linux and Windows.

Installation on the Linux platform

Most Linux distributions have Python 2 in their default installations. Some of them also have Python 3 included.
To install python3 on Debian-based Linux, run the following command in the Terminal:
sudo apt install python3
To install python3 on centos, run the following command in the Terminal:
sudo yum install python3
If you are unable to install Python using the preceding commands, download Python from https://www.python.org/downloads/ and follow the instructions.

Installation on the Windows platform

For installing Python in Microsoft Windows, you'll have to download the executable from python.org and install it. Download python.exe from https://www.python.org/downloa...

Índice