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)

Chapter 14, Working with Apache and Other Log Files

  1. Runtime exceptions occur during execution of the program and they exit abruptly in between. Compile time exceptions are those that are found before program executions start.
  2. A regular expression, regex, or regexp is a sequence of characters that define a search pattern. Usually this pattern is used by string searching algorithms for find or find and replace operations on strings, or for input validation.
  3. Here's a description of the Linux commands:
    • head: used to see the first N number of lines of plain files.
    • tail: used to see the last N number of lines of plain files.
    • cat: used to see the content of plain files.
    • awk: AWK is a programming language designed for text processing and typically used as a data extraction and reporting tool. It is a standard feature of most Unix-like operating systems.
  4. Following is the answer...