Название: Scripting: Automation with Bash, PowerShell, and Python Автор: Michael Kofler Издательство: Rheinwerk Publishing Inc. Год: 2024 Страниц: 473 Язык: английский Формат: pdf (true), epub (true) Размер: 13.6 MB
Developers and admins, it’s time to simplify your workday. With this practical guide, use scripting to solve tedious IT problems with less effort and less code! Learn about popular scripting languages: Bash, PowerShell, and Python. Master important techniques such as working with Linux, cmdlets, regular expressions, JSON, SSH, Git, and more. Use scripts to automate different scenarios, from backups and image processing to virtual machine management. Discover what’s possible with only 10 lines of code!
A script is a small piece of code to solve a specific problem or automate a tedious task. You don’t need a development environment or a compiler to develop a script—an editor is enough. When it comes to scripting, minimalism is the name of the game, and its goal is achieving maximum impact with minimal resources. To put it casually, scripting is the art of solving IT problems in ten lines of code.
The “classic” scripting language is Bash. Its full name, Bourne Again Shell, is a pun. The predecessor was the Bourne shell, which was widely used on Unix. The license for the Bourne shell was unsuitable for Linux, which is why a new project was created. Today, Bash is the dominant Linux shell, both in interactive mode for executing commands and for script programming. macOS relies on the largely compatible Zsh, which is also gaining more and more followers on Linux.
Bash is popular, but its antiquated syntax doesn’t win any beauty contests. On the contrary, Bash scripts sometimes look awful. For this reason, Microsoft did not even try to adapt Bash for Windows. Instead, with PowerShell, Microsoft has combined the basic ideas of a classic Unix shell with the concepts behind object-oriented programming languages and created a completely new language, which turned out surprisingly well! Not without reason, Windows administrators love PowerShell.
Python is actually not a typical scripting language. Depending on the intended use, Python is the basis for AI developments, a tool for (natural) scientists, or a first language for entry-level programming. Probably no other language is used as universally as Python! The elegance of Python’s syntax and its almost inexhaustible supply of extension modules have led to Python also being used for system administration, converting files between different formats, as a database tool or for hardware control (for the Raspberry Pi). Python plays to its strengths the more complex the task.
Because no single perfect scripting language exists, this book starts in Part I with crash courses for the Bash, PowerShell, and Python languages. If you want, you can focus on one of these three languages to get started and gradually increase your language vocabulary.
Part II of this book introduces you to tools and working techniques typically used in scripts: These topics include commands for processing text files, cmdlets for applying regular expressions, and functions for handling JSON and XML files. I’ll show you how to run scripts regularly and automatically, how to run code or copy files to other machines via SSH, and how to combine version management for your code and scripting via Git. Many practical examples round off the information I provide throughout this book.
Finally, Part III deals with concrete applications: Key topics include backups, image processing, web scraping, using REST APIs, databases, using the cloud, and virtual machine administration.
In this book, you’ll learn аbout:
a. Scripting Languages Beginners, get the crash course you need in Bash (and its alternative, Zsh), PowerShell, and Python syntax to perform scripting tasks.
b. Scripting Techniques Learn to write successful scripts by following expert guidance and practical examples. Use commands for processing text files, functions for handling JSON and XML files, cron for automating script execution, SSH for running code, and more.
c. Scripting Examples See scripting in action! Walk through concrete applications of scripting: data backup, image processing, web scraping, REST APIs, database maintenance, cloud scenarios, and virtual machine administration.
Highlights include:
1) Bash and Zsh 2) Linux toolbox 3) PowerShell and CmdLets 4) Python and pip 5) JSON, XML, and INI 6) SSH, VS Code, and Git 7) Automation with cron 8) Backup automation 9) Image processing 10) Web scraping 11) Cloud scripting 12) Virtual machines
Скачать Scripting: Automation with Bash, PowerShell, and Python
|