Zum Hauptinhalt springen
Dekorationsartikel gehören nicht zum Leistungsumfang.
Scripting
Automation with Bash, PowerShell, and Python
Taschenbuch von Michael Kofler
Sprache: Englisch

46,80 €*

inkl. MwSt.

Versandkostenfrei per Post / DHL

Lieferzeit 2-3 Wochen

Kategorien:
Beschreibung

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!


In this book, you'll learn about:


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

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!


In this book, you'll learn about:


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

Über den Autor
Dr. Michael Kofler is a programmer and Linux administrator. He studied electrical engineering/telematics at Graz University of Technology. He has been one of the most successful and versatile computing authors in the German-speaking world for many years. His current topics include Linux, Docker, Git, hacking and security, Raspberry Pi, and the programming languages Swift, Java, Python, and Kotlin. Michael Kofler also teaches at the Joanneum University of Applied Sciences in Kapfenberg, Austria.
Zusammenfassung
Automate key tasks, including backups, database updates, image processing, and web scraping
Inhaltsverzeichnis
... Preface ... 23

... Bash, PowerShell, or Python? ... 23

... About This Book ... 24

PART I ... Scripting Languages ... 27

1 ... Scripting: Doing One Thing ... 29

1.1 ... What Does Scripting Mean? ... 29

1.2 ... Scripting Languages ... 31

1.3 ... The Agony of Choice ... 35

2 ... Ten Times Ten Lines ... 39

2.1 ... Markdown Spell Checker (Bash) ... 39

2.2 ... Sorting Images by Date (PowerShell) ... 40

2.3 ... Converting a JSON File to XML Format (Python) ... 41

2.4 ... Daily Server Backups (Bash) ... 42

2.5 ... Web Scraping (Python) ... 43

2.6 ... Logging Weather Data (Python) ... 44

2.7 ... Microsoft Hyper-V Cleanup (PowerShell) ... 45

2.8 ... Statistical Analysis of a Logging File (Bash) ... 46

2.9 ... Uploading Files to the Cloud (PowerShell) ... 46

2.10 ... Cloning Virtual Machines (Bash) ... 47

3 ... Bash and Zsh ... 49

3.1 ... Terminal, Shell, and Bash ... 49

3.2 ... Installation ... 50

3.3 ... Running Commands Interactively ... 53

3.4 ... Zsh as an Alternative to Bash ... 56

3.5 ... The First Bash Script ... 58

3.6 ... Running Commands ... 63

3.7 ... Standard Input and Standard Output ... 66

3.8 ... Globbing, Brace Extension, and Handling File and Directory Names ... 68

3.9 ... Variables ... 72

3.10 ... Strings ... 77

3.11 ... Branches ... 85

3.12 ... Loops ... 91

3.13 ... Functions ... 95

3.14 ... Error Protection ... 96

4 ... PowerShell ... 99

4.1 ... Installation ... 99

4.2 ... Windows Terminal ... 103

4.3 ... Calling cmdlets and Functions ... 106

4.4 ... Combining Commands ... 112

4.5 ... The First Script ... 114

4.6 ... Variables, Strings, and Objects ... 120

4.7 ... Arrays and Hash Tables ... 131

4.8 ... Output Redirection ... 133

4.9 ... Loops ... 137

4.10 ... Branches ... 139

4.11 ... Functions and Parameters ... 141

4.12 ... Modules ... 147

4.13 ... Error Protection ... 149

5 ... Python ... 153

5.1 ... Installing Python ... 153

5.2 ... Getting to Know Python in a Terminal Window ... 156

5.3 ... Programming Custom Scripts ... 157

5.4 ... Elementary Syntax Rules ... 158

5.5 ... Numbers ... 160

5.6 ... Strings ... 162

5.7 ... Lists ... 169

5.8 ... Tuples, Sets, and Dictionaries ... 171

5.9 ... Variables ... 174

5.10 ... Operators ... 178

5.11 ... Branches (if) ... 180

5.12 ... Loops (for and while) ... 181

5.13 ... Functions ... 187

5.14 ... Processing Text Files ... 192

5.15 ... Error Protection ... 195

5.16 ... System Functions ... 195

5.17 ... Modules ... 198

5.18 ... Installing Additional Modules Using pip ... 199

PART II ... Work Techniques and Tools ... 205

6 ... Linux Toolbox ... 207

6.1 ... Directories and Files ... 207

6.2 ... Finding Files ... 209

6.3 ... Compressing and Archiving Files ... 210

6.4 ... Using Root Privileges ... 212

6.5 ... Software Installation ... 218

6.6 ... Other Commands ... 220

7 ... cmdlets for PowerShell ... 223

7.1 ... Directories and Files ... 223

7.2 ... Finding Files ... 227

7.3 ... Compressing and Archiving Files ... 230

7.4 ... Process Management ... 232

7.5 ... Registration Database and System Information ... 235

7.6 ... Processing cmdlet Results ... 238

7.7 ... Other cmdlets ... 243

7.8 ... Installing Additional Modules ... 243

7.9 ... Standard Aliases ... 246

8 ... Analyzing Texts with Filters and Pipes ... 249

8.1 ... grep, sort, cut, and uniq ... 249

8.2 ... Example: Statistical Data Analysis ... 256

8.3 ... Example: ping Analysis ... 258

8.4 ... Example: Apache Log Analysis ... 260

8.5 ... CSV Files ... 263

9 ... Regular Expressions ... 267

9.1 ... Syntax Rules for Regular Expressions ... 268

9.2 ... Groups and Alternatives ... 270

9.3 ... Regular Expressions in Bash (grep, sed) ... 276

9.4 ... Regular Expressions in PowerShell ... 280

9.5 ... Regular Expressions in Python (re Module) ... 283

10 ... JSON, XML, and INI ... 287

10.1 ... JSON in PowerShell ... 287

10.2 ... JSON and Python ... 290

10.3 ... JSON in Bash ... 295

10.4 ... XML in PowerShell ... 298

10.5 ... XML and Python ... 302

10.6 ... XML in Bash ... 305

10.7 ... INI Files ... 307

11 ... Running Scripts Automatically ... 309

11.1 ... cron ... 309

11.2 ... Example: Web Server Monitoring ... 313

11.3 ... Microsoft Windows Task Scheduler ... 315

11.4 ... Example: Saving Exchange Rates ... 319

11.5 ... Tracking File System Changes ... 320

12 ... SSH ... 323

12.1 ... Installing the SSH Client and Server ... 323

12.2 ... Working with SSH ... 327

12.3 ... scp and rsync ... 332

12.4 ... SSH Authentication with Keys ... 333

12.5 ... Example: Uploading Images to a Linux Web Server ... 336

12.6 ... Example: Analyzing Virtual Machines ... 339

13 ... Visual Studio Code ... 341

13.1 ... Introduction ... 341

13.2 ... Language-Specific VS Code Extensions ... 343

13.3 ... Remote - SSH Extension ... 345

14 ... Git ... 347

14.1 ... Git Crash Course ... 348

14.2 ... Handling Settings and Passwords Correctly ... 355

14.3 ... Git Automation ... 358

14.4 ... Git Hooks ... 360

PART III ... Applications and Examples ... 363

15 ... Backups ... 365

15.1 ... Synchronizing Directories to External Storage ... 365

15.2 ... WordPress Backup ... 370

15.3 ... SQL Server Backup ... 372

16 ... Image Processing ... 375

16.1 ... Manipulating Image Files ... 375

16.2 ... Sorting Photos by Date Taken ... 379

16.3 ... Converting Exif Metadata to SQL Commands ... 382

17 ... Web Scraping ... 389

17.1 ... Limitations ... 389

17.2 ... Web Scraping, Web Crawling, and Data Mining ... 390

17.3 ... Downloading Websites Using wget ... 390

17.4 ... Web Scraping with Regular Expressions ... 393

17.5 ... Web Scraping with Beautiful Soup ... 395

17.6 ... Web Scraping with Requests-HTML ... 399

17.7 ... Web Scraping with PowerShell ... 401

18 ... Using REST APIs ... 405

18.1 ... Tools ... 405

18.2 ... Sample APIs to Try Out ... 406

18.3 ... Implementing Custom REST APIs ... 406

18.4 ... curl and wget ... 406

18.5 ... Using REST APIs in PowerShell ... 411

18.6 ... Example: Determining the Current Weather ... 413

18.7 ... Using REST APIs in Python ... 414

18.8 ... Example: Determining Electricity Prices and Displaying Them Graphically ... 416

19 ... Databases ... 421

19.1 ... Updating and Maintaining Databases ... 422

19.2 ... Creating a New Customer Account ... 423

19.3 ... Storing Exif Metadata in a Database ... 426

19.4 ... Importing JSON Data into a Table ... 429

20 ... Scripting in the Cloud ... 433

20.1 ... AWS CLI ... 433

20.2 ... Example: Uploading Encrypted Backup Files to the Cloud ... 438

20.3 ... AWS PowerShell Module ... 439

20.4 ... Example: Offloading Large Files from a Website to the Cloud ... 442

21 ... Virtual Machines ... 447

21.1 ... Setting Up and Running Virtual Machines (KVMs) ... 447

21.2 ... Automating the Network Configuration (KVMs) ... 450

21.3 ... Controlling Hyper-V ... 453

... The Author ... 459

... Index ... 461
Details
Erscheinungsjahr: 2024
Fachbereich: Programmiersprachen
Genre: Importe, Informatik
Rubrik: Naturwissenschaften & Technik
Medium: Taschenbuch
Reihe: Rheinwerk Computing
Inhalt: 470 S.
ISBN-13: 9781493225569
ISBN-10: 1493225561
Sprache: Englisch
Einband: Klappenbroschur
Autor: Kofler, Michael
Hersteller: Rheinwerk Verlag GmbH
Rheinwerk Publishing Inc.
Maße: 254 x 176 x 26 mm
Von/Mit: Michael Kofler
Erscheinungsdatum: 03.07.2024
Gewicht: 0,816 kg
Artikel-ID: 127959195
Über den Autor
Dr. Michael Kofler is a programmer and Linux administrator. He studied electrical engineering/telematics at Graz University of Technology. He has been one of the most successful and versatile computing authors in the German-speaking world for many years. His current topics include Linux, Docker, Git, hacking and security, Raspberry Pi, and the programming languages Swift, Java, Python, and Kotlin. Michael Kofler also teaches at the Joanneum University of Applied Sciences in Kapfenberg, Austria.
Zusammenfassung
Automate key tasks, including backups, database updates, image processing, and web scraping
Inhaltsverzeichnis
... Preface ... 23

... Bash, PowerShell, or Python? ... 23

... About This Book ... 24

PART I ... Scripting Languages ... 27

1 ... Scripting: Doing One Thing ... 29

1.1 ... What Does Scripting Mean? ... 29

1.2 ... Scripting Languages ... 31

1.3 ... The Agony of Choice ... 35

2 ... Ten Times Ten Lines ... 39

2.1 ... Markdown Spell Checker (Bash) ... 39

2.2 ... Sorting Images by Date (PowerShell) ... 40

2.3 ... Converting a JSON File to XML Format (Python) ... 41

2.4 ... Daily Server Backups (Bash) ... 42

2.5 ... Web Scraping (Python) ... 43

2.6 ... Logging Weather Data (Python) ... 44

2.7 ... Microsoft Hyper-V Cleanup (PowerShell) ... 45

2.8 ... Statistical Analysis of a Logging File (Bash) ... 46

2.9 ... Uploading Files to the Cloud (PowerShell) ... 46

2.10 ... Cloning Virtual Machines (Bash) ... 47

3 ... Bash and Zsh ... 49

3.1 ... Terminal, Shell, and Bash ... 49

3.2 ... Installation ... 50

3.3 ... Running Commands Interactively ... 53

3.4 ... Zsh as an Alternative to Bash ... 56

3.5 ... The First Bash Script ... 58

3.6 ... Running Commands ... 63

3.7 ... Standard Input and Standard Output ... 66

3.8 ... Globbing, Brace Extension, and Handling File and Directory Names ... 68

3.9 ... Variables ... 72

3.10 ... Strings ... 77

3.11 ... Branches ... 85

3.12 ... Loops ... 91

3.13 ... Functions ... 95

3.14 ... Error Protection ... 96

4 ... PowerShell ... 99

4.1 ... Installation ... 99

4.2 ... Windows Terminal ... 103

4.3 ... Calling cmdlets and Functions ... 106

4.4 ... Combining Commands ... 112

4.5 ... The First Script ... 114

4.6 ... Variables, Strings, and Objects ... 120

4.7 ... Arrays and Hash Tables ... 131

4.8 ... Output Redirection ... 133

4.9 ... Loops ... 137

4.10 ... Branches ... 139

4.11 ... Functions and Parameters ... 141

4.12 ... Modules ... 147

4.13 ... Error Protection ... 149

5 ... Python ... 153

5.1 ... Installing Python ... 153

5.2 ... Getting to Know Python in a Terminal Window ... 156

5.3 ... Programming Custom Scripts ... 157

5.4 ... Elementary Syntax Rules ... 158

5.5 ... Numbers ... 160

5.6 ... Strings ... 162

5.7 ... Lists ... 169

5.8 ... Tuples, Sets, and Dictionaries ... 171

5.9 ... Variables ... 174

5.10 ... Operators ... 178

5.11 ... Branches (if) ... 180

5.12 ... Loops (for and while) ... 181

5.13 ... Functions ... 187

5.14 ... Processing Text Files ... 192

5.15 ... Error Protection ... 195

5.16 ... System Functions ... 195

5.17 ... Modules ... 198

5.18 ... Installing Additional Modules Using pip ... 199

PART II ... Work Techniques and Tools ... 205

6 ... Linux Toolbox ... 207

6.1 ... Directories and Files ... 207

6.2 ... Finding Files ... 209

6.3 ... Compressing and Archiving Files ... 210

6.4 ... Using Root Privileges ... 212

6.5 ... Software Installation ... 218

6.6 ... Other Commands ... 220

7 ... cmdlets for PowerShell ... 223

7.1 ... Directories and Files ... 223

7.2 ... Finding Files ... 227

7.3 ... Compressing and Archiving Files ... 230

7.4 ... Process Management ... 232

7.5 ... Registration Database and System Information ... 235

7.6 ... Processing cmdlet Results ... 238

7.7 ... Other cmdlets ... 243

7.8 ... Installing Additional Modules ... 243

7.9 ... Standard Aliases ... 246

8 ... Analyzing Texts with Filters and Pipes ... 249

8.1 ... grep, sort, cut, and uniq ... 249

8.2 ... Example: Statistical Data Analysis ... 256

8.3 ... Example: ping Analysis ... 258

8.4 ... Example: Apache Log Analysis ... 260

8.5 ... CSV Files ... 263

9 ... Regular Expressions ... 267

9.1 ... Syntax Rules for Regular Expressions ... 268

9.2 ... Groups and Alternatives ... 270

9.3 ... Regular Expressions in Bash (grep, sed) ... 276

9.4 ... Regular Expressions in PowerShell ... 280

9.5 ... Regular Expressions in Python (re Module) ... 283

10 ... JSON, XML, and INI ... 287

10.1 ... JSON in PowerShell ... 287

10.2 ... JSON and Python ... 290

10.3 ... JSON in Bash ... 295

10.4 ... XML in PowerShell ... 298

10.5 ... XML and Python ... 302

10.6 ... XML in Bash ... 305

10.7 ... INI Files ... 307

11 ... Running Scripts Automatically ... 309

11.1 ... cron ... 309

11.2 ... Example: Web Server Monitoring ... 313

11.3 ... Microsoft Windows Task Scheduler ... 315

11.4 ... Example: Saving Exchange Rates ... 319

11.5 ... Tracking File System Changes ... 320

12 ... SSH ... 323

12.1 ... Installing the SSH Client and Server ... 323

12.2 ... Working with SSH ... 327

12.3 ... scp and rsync ... 332

12.4 ... SSH Authentication with Keys ... 333

12.5 ... Example: Uploading Images to a Linux Web Server ... 336

12.6 ... Example: Analyzing Virtual Machines ... 339

13 ... Visual Studio Code ... 341

13.1 ... Introduction ... 341

13.2 ... Language-Specific VS Code Extensions ... 343

13.3 ... Remote - SSH Extension ... 345

14 ... Git ... 347

14.1 ... Git Crash Course ... 348

14.2 ... Handling Settings and Passwords Correctly ... 355

14.3 ... Git Automation ... 358

14.4 ... Git Hooks ... 360

PART III ... Applications and Examples ... 363

15 ... Backups ... 365

15.1 ... Synchronizing Directories to External Storage ... 365

15.2 ... WordPress Backup ... 370

15.3 ... SQL Server Backup ... 372

16 ... Image Processing ... 375

16.1 ... Manipulating Image Files ... 375

16.2 ... Sorting Photos by Date Taken ... 379

16.3 ... Converting Exif Metadata to SQL Commands ... 382

17 ... Web Scraping ... 389

17.1 ... Limitations ... 389

17.2 ... Web Scraping, Web Crawling, and Data Mining ... 390

17.3 ... Downloading Websites Using wget ... 390

17.4 ... Web Scraping with Regular Expressions ... 393

17.5 ... Web Scraping with Beautiful Soup ... 395

17.6 ... Web Scraping with Requests-HTML ... 399

17.7 ... Web Scraping with PowerShell ... 401

18 ... Using REST APIs ... 405

18.1 ... Tools ... 405

18.2 ... Sample APIs to Try Out ... 406

18.3 ... Implementing Custom REST APIs ... 406

18.4 ... curl and wget ... 406

18.5 ... Using REST APIs in PowerShell ... 411

18.6 ... Example: Determining the Current Weather ... 413

18.7 ... Using REST APIs in Python ... 414

18.8 ... Example: Determining Electricity Prices and Displaying Them Graphically ... 416

19 ... Databases ... 421

19.1 ... Updating and Maintaining Databases ... 422

19.2 ... Creating a New Customer Account ... 423

19.3 ... Storing Exif Metadata in a Database ... 426

19.4 ... Importing JSON Data into a Table ... 429

20 ... Scripting in the Cloud ... 433

20.1 ... AWS CLI ... 433

20.2 ... Example: Uploading Encrypted Backup Files to the Cloud ... 438

20.3 ... AWS PowerShell Module ... 439

20.4 ... Example: Offloading Large Files from a Website to the Cloud ... 442

21 ... Virtual Machines ... 447

21.1 ... Setting Up and Running Virtual Machines (KVMs) ... 447

21.2 ... Automating the Network Configuration (KVMs) ... 450

21.3 ... Controlling Hyper-V ... 453

... The Author ... 459

... Index ... 461
Details
Erscheinungsjahr: 2024
Fachbereich: Programmiersprachen
Genre: Importe, Informatik
Rubrik: Naturwissenschaften & Technik
Medium: Taschenbuch
Reihe: Rheinwerk Computing
Inhalt: 470 S.
ISBN-13: 9781493225569
ISBN-10: 1493225561
Sprache: Englisch
Einband: Klappenbroschur
Autor: Kofler, Michael
Hersteller: Rheinwerk Verlag GmbH
Rheinwerk Publishing Inc.
Maße: 254 x 176 x 26 mm
Von/Mit: Michael Kofler
Erscheinungsdatum: 03.07.2024
Gewicht: 0,816 kg
Artikel-ID: 127959195
Warnhinweis

Ähnliche Produkte

Ähnliche Produkte