Contents

About the Author

About the Technical Reviewer

Acknowledgments

Introduction


PART 1   Basic Scripting Techniques

CHAPTER 1 Shell Script Debugging

                       Shell Trace Options

                       Simple Output Statements

                       Controlling Output with Debug Levels

                       Simplifying Error Checking with a Function

                       Manual Stepping

CHAPTER 2 Standard Function Library

                       The Library File

                       Some Useful Functions

                       Using Your Library

CHAPTER 3 Date and Time Manipulation

                       Date in Days

                             Days Since Epoch

                             Alternatives for Finding the Date in Seconds

                       Evaluating for the Current Day and Time

CHAPTER 4 Comparisons and Tests

                       The Basics of Comparisons

CHAPTER 5 Accepting Command-Line Options, Switches, and Parameters

CHAPTER 6 Testing Variables and Assigning Defaults

                       Setting Defaults

                       Variable Substitution

                             := Syntax

                             = Syntax

                             :- Syntax

                             - Syntax

                             :? Syntax

                             ? Syntax

                             :+ Syntax

                             + Syntax

CHAPTER 7 Indirect Reference Variables

                       Log File Monitoring with Indirect Variables

                       The Main Monitor Loop

CHAPTER 8 Shell Process Tree

                       Process Tree Implemented Using Arrays

                       Process Tree Implemented Using Indirect Variables

                       Bourne Shell Implementation of a Process Tree

CHAPTER 9 Data Redirection

                       Avoiding Confusion

                       Common Redirection

                       Access to User-Specified File Handles

                       Descriptor Access from the Shell

CHAPTER 10 Piping Input to read

                       Line-by-Line Option 1

                       Line-by-Line Option 2

                       Line-by-Line Option 3

                       Line-by-Line Option 4

                       Pipe to read Directly

                       Process Input Word-by-Word

PART 2   System Interaction and Advanced Techniques

CHAPTER 11 Math from the Shell

                       expr

                       Internal Shell Math

                       bc

                       dc

CHAPTER 12 cron

                       crontab Entries

                       Environment Problems

                       Output Redirection

CHAPTER 13 Self-Linked Scripts

CHAPTER 14 Throttling Parallel Processes

                       Parallel Processing with ksh

                       Parallel Processing with bash

CHAPTER 15 Command-Line Editing and History

                       Setting Up vi Editing

                             bash

                             ksh

                       Command and File Completion

CHAPTER 16 Scripting from the Command Line

                       A Few Examples

CHAPTER 17 Automating User Input with expect

                       A Shell Script to Customize Parameters for an expect Script

                       An expect Script to Automate telnet

CHAPTER 18 User Input Timeout

                       Manual Timeout Method

                       Timeout Using stty

                       General Timeout Utility

CHAPTER 19 Instant Keyboard Response

CHAPTER 20 Directory Copying

                       Using cp

                       Using tar

                       Using find

                       Using rsync

CHAPTER 21 A Brief Tour of the X Display Environment

                       The Display

                       X Traffic Through ssh

                       X Applications Through a Third-Party System

                       User-Profile Entry

                       Root-Profile Entry

                       Throw a Temporary Root Window

CHAPTER 22 X Navigation Window

                       Navigation Window Usage

                       Navigation Setup

                       Navigation Window

CHAPTER 23 Command-Line E-mail Attachments

                       uuencode

                       MIME Encoding

CHAPTER 24 Text-Processing One-Liners

                       Displaying Specific Fields

                       Specifying the Field Separator

                       Simple Pattern-Matching

                       Matching Fields Against Several Values

                       Determining the Number of Fields

                       Determining the Last Field

                       Determining the Second-to-Last Field

                       Passing Variables to awk

                       Using a Variable Passed to awk in a Condition

                       Displaying a Range of Fields (Main Method)

                       Displaying a Range of Fields (Alternate Method)

                       Determining the Length of a String Using awk

                       Determining the Length of a String Using expr

                       Displaying a Substring with awk

                       Displaying a Substring with expr

                       Conducting Simple Search and Replace with sed

                       Disregarding Blank and Commented Lines from a File

                       Conducting Dual Search and Replace with sed

                       Filtering Lines with sed

                       Searching for Multiple Strings with egrep

                       A Clean Method of Searching the Process Table

                       Summing Columns Using awk

                       Generating Random Numbers Using awk

                       Generating Random Numbers from the Shell

                       Displaying Character-Based Fields with sed

                       Escaping Special Characters

                       Returning Trailing Lines from a Pattern Match Using grep

                       Returning Preceding Lines to a Pattern Match Using grep

CHAPTER 25 Editing Files in Place

                       Simple Search and Replace with ed

                       Search and Replace Using ed, Dissected

                       Examples of ed Commands

                       Escaping Special Characters in a File

CHAPTER 26 Evaluating Variables in a Flat File

CHAPTER 27 Read Piped Input

CHAPTER 28 Free-Format Output Using cat

CHAPTER 29 Automating Interactive Processes

PART 3   Useful Scripts

CHAPTER 30 Automating E-mail with procmail

                       The .procmailrc File

                       Usage Examples

                       The Code

CHAPTER 31 Process-Management Monitor

CHAPTER 32 Managing File Counts

                       File-Count Monitor

                       Testing File-Count Methods

CHAPTER 33 Processes Running from inittab

CHAPTER 34 Automatic RCS

CHAPTER 35 Colorful /proc Reporting

CHAPTER 36 Password-Aging Notification

                       Script Initialization

                       Processing Begins

                       Determine Password Age

CHAPTER 37 A Pseudo–shadow File

CHAPTER 38 Linux Gold-System Build

CHAPTER 39 System Snapshots

                       Snapshot Script

                       Snapshot Promotion

                       Creating the Latest Snapshot

                       Final Thoughts

CHAPTER 40 Removing Large Files and Log Rolling

CHAPTER 41 Core Finder

CHAPTER 42 Network Adapter Failover

                       Check the Network

                       Switch the Interfaces

APPENDIX A Test Switches

APPENDIX B Special Parameters

APPENDIX C Other Shell-Scripting Resources

                       Manual Pages

                       Books

                             Scripting Books

                             Supplementary Books

                       Shell Resources

                       Online Resources

INDEX

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.253.106