Scripting
Book 1
Book 2
Book 3
Book 1
Book 2
Book 3
Book 1
Book 2
Book 3
Book 1
Book 2
Book 3
Home > Computing and Information Technology > Computer programming / software engineering > Programming and scripting languages: general > Scripting
Scripting

Scripting


     0     
5
4
3
2
1



International Edition


X
About the Book

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

Table of Contents:
... 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

About the Author :
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.


Best Sellers


Product Details
  • ISBN-13: 9781493225569
  • Publisher: Rheinwerk Publishing Inc.
  • Publisher Imprint: Rheinwerk Computing
  • Height: 254 mm
  • No of Pages: 470
  • Width: 178 mm
  • ISBN-10: 1493225561
  • Publisher Date: 26 Mar 2024
  • Binding: Paperback
  • Language: English
  • Returnable: Y


Similar Products

Add Photo
Add Photo

Customer Reviews

REVIEWS      0     
Click Here To Be The First to Review this Product
Scripting
Rheinwerk Publishing Inc. -
Scripting
Writing guidlines
We want to publish your review, so please:
  • keep your review on the product. Review's that defame author's character will be rejected.
  • Keep your review focused on the product.
  • Avoid writing about customer service. contact us instead if you have issue requiring immediate attention.
  • Refrain from mentioning competitors or the specific price you paid for the product.
  • Do not include any personally identifiable information, such as full names.

Scripting

Required fields are marked with *

Review Title*
Review
    Add Photo Add up to 6 photos
    Would you recommend this product to a friend?
    Tag this Book Read more
    Does your review contain spoilers?
    What type of reader best describes you?
    I agree to the terms & conditions
    You may receive emails regarding this submission. Any emails will include the ability to opt-out of future communications.

    CUSTOMER RATINGS AND REVIEWS AND QUESTIONS AND ANSWERS TERMS OF USE

    These Terms of Use govern your conduct associated with the Customer Ratings and Reviews and/or Questions and Answers service offered by Bookswagon (the "CRR Service").


    By submitting any content to Bookswagon, you guarantee that:
    • You are the sole author and owner of the intellectual property rights in the content;
    • All "moral rights" that you may have in such content have been voluntarily waived by you;
    • All content that you post is accurate;
    • You are at least 13 years old;
    • Use of the content you supply does not violate these Terms of Use and will not cause injury to any person or entity.
    You further agree that you may not submit any content:
    • That is known by you to be false, inaccurate or misleading;
    • That infringes any third party's copyright, patent, trademark, trade secret or other proprietary rights or rights of publicity or privacy;
    • That violates any law, statute, ordinance or regulation (including, but not limited to, those governing, consumer protection, unfair competition, anti-discrimination or false advertising);
    • That is, or may reasonably be considered to be, defamatory, libelous, hateful, racially or religiously biased or offensive, unlawfully threatening or unlawfully harassing to any individual, partnership or corporation;
    • For which you were compensated or granted any consideration by any unapproved third party;
    • That includes any information that references other websites, addresses, email addresses, contact information or phone numbers;
    • That contains any computer viruses, worms or other potentially damaging computer programs or files.
    You agree to indemnify and hold Bookswagon (and its officers, directors, agents, subsidiaries, joint ventures, employees and third-party service providers, including but not limited to Bazaarvoice, Inc.), harmless from all claims, demands, and damages (actual and consequential) of every kind and nature, known and unknown including reasonable attorneys' fees, arising out of a breach of your representations and warranties set forth above, or your violation of any law or the rights of a third party.


    For any content that you submit, you grant Bookswagon a perpetual, irrevocable, royalty-free, transferable right and license to use, copy, modify, delete in its entirety, adapt, publish, translate, create derivative works from and/or sell, transfer, and/or distribute such content and/or incorporate such content into any form, medium or technology throughout the world without compensation to you. Additionally,  Bookswagon may transfer or share any personal information that you submit with its third-party service providers, including but not limited to Bazaarvoice, Inc. in accordance with  Privacy Policy


    All content that you submit may be used at Bookswagon's sole discretion. Bookswagon reserves the right to change, condense, withhold publication, remove or delete any content on Bookswagon's website that Bookswagon deems, in its sole discretion, to violate the content guidelines or any other provision of these Terms of Use.  Bookswagon does not guarantee that you will have any recourse through Bookswagon to edit or delete any content you have submitted. Ratings and written comments are generally posted within two to four business days. However, Bookswagon reserves the right to remove or to refuse to post any submission to the extent authorized by law. You acknowledge that you, not Bookswagon, are responsible for the contents of your submission. None of the content that you submit shall be subject to any obligation of confidence on the part of Bookswagon, its agents, subsidiaries, affiliates, partners or third party service providers (including but not limited to Bazaarvoice, Inc.)and their respective directors, officers and employees.

    Accept

    Fresh on the Shelf


    Inspired by your browsing history


    Your review has been submitted!

    You've already reviewed this product!