Mastering Unix Shell Scripting - Lagout

Transcription

Free & Share & OpenMastering UnixShell ScriptingRandal K. Michael

Publisher: Robert IpsenExecutive Editor: Carol LongDevelopmental Editor: Scott AmermanManaging Editor: Angela SmithText Design & Composition: Wiley Composition ServicesThis book is printed on acid-free paper. Copyright 2003 by Randal K. Michael. All rights reserved.Published by Wiley Publishing, Inc., Indianapolis, IndianaPublished simultaneously in CanadaNo part of this publication may be reproduced, stored in a retrieval system, or transmittedin any form or by any means, electronic, mechanical, photocopying, recording, scanning, orotherwise, except as permitted under Section 107 or 108 of the 1976 United States CopyrightAct, without either the prior written permission of the Publisher, or authorization throughpayment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc.,10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-mail:PERMCOORDINATOR@WILEY.COM.Limit of Liability/Disclaimer of Warranty: While the publisher and author have used theirbest efforts in preparing this book, they make no representations or warranties with respectto the accuracy or completeness of the contents of this book and specifically disclaim anyimplied warranties of merchantability or fitness for a particular purpose. No warranty maybe created or extended by sales representatives or written sales materials. The advice andstrategies contained herein may not be suitable for your situation. You should consult witha professional where appropriate. Neither the publisher nor author shall be liable for anyloss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.For general information on our other products and services please contact our CustomerCare Department within the United States at (800) 762-2974, outside the United States at(317) 572-3993 or fax (317) 572-4002.Trademarks: Wiley, the Wiley Publishing logo and related trade dress are trademarks orregistered trademarks of Wiley Publishing, Inc., in the United States and other countries,and may not be used without written permission. All other trademarks are the property oftheir respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.Wiley also publishes its books in a variety of electronic formats. Some content that appearsin print may not be available in electronic books.Library of Congress Cataloging-in-Publication Data:ISBN: 0-471-21821-9Printed in the United States of America10 9 8 7 6 5 4 3 2 1

Free & Share & OpenThis book is dedicated toMy Wife Robin,and the girls, Andrea and Ana

AcknowledgmentsThe information that I gathered together in this book is the result of working withsome of the most talented UNIX professionals on the topic. I have enjoyed everyminute of my association with these UNIX gurus and it has been my pleasure to havethe opportunity to gain so much knowledge from the pros. I want to thank every oneof these experts for asking and answering questions over the last fifteen years. If mybrother, Jim, had not kept telling me, “you should write a book,” after querying me forUNIX details on almost a weekly basis, I doubt this book would have ever been written. So, thanks Jim!I especially want to thank Jack Renfro at Daimler/Chrysler Corporation for givingme my first shell scripting project so long ago. I had to start with the man pages, butthat is how I learned to dig deep to get an answer. Since then I have been on a missionto automate, through shell scripting, everything on every system that I come in contactwith. I certainly value the years that I was able to work with Jack.I must also thank the talented people at Wiley Publishing. Margaret Eldridge startedme on this project by letting me do my own thing, and Carol Long kept me going. ScottAmerman kept me on schedule, and Angela Smith did the edits that make my writingflow with ease. It has been a valuable experience for me to work with such a fine groupof professionals at Wiley. I also want to thank Carole McClendon at Waterside Productions for all of the support on this project. Carole is the best Agent that anyone couldever ask for. She is a true professional with the highest ethics.Of course my family had a lot to do with my success on this and every project. Iwant to thank Mom, Gene, Jim, Marcia, Rusty, Mallory, and Anica. I want to thank myWife Robin for her understanding and support. The girls, Andrea and Ana, alwayskeep a smile on my face, and Steve is always on my mind.I could not have written this book without the support of all of these people and themany others that remain unnamed. It has been an honor!Free & Share & Openvii

ContentsAcknowledgmentsviiIntroductionxixChapter 1Free & Share & OpenScripting Quick Start and ReviewCase SensitivityUnix Special CharactersShellsShell ScriptsFunctionsA Function Has the FormRunning a Shell Script11222233Declare the Shell in the Shell Script3Comments and Style in Shell ScriptsControl StructuresUsing break, continue, exit, and returnHere Document4699Syntax for a Here Document9Shell Script CommandsSymbol CommandsVariablesCommand-Line ArgumentsShift CommandSpecial Parameters * and @101313131415Special Parameter DefinitionsDouble Quotes “, Forward Tics ‘, and Back Tics Math in a Shell ScriptOperatorsBuilt-in Mathematical Functions1516171718ix

xContentsFile Permissions, suid and sgid Programschmod Command Syntax for Each PurposeRunning Commands on a Remote HostSetting TrapsUser Information Commandswho Commandw Commandlast Commandps CommandCommunicating with UsersUppercase or Lowercase Text for Easy TestingCheck the Return CodeTime-Based Script Executioncron tablesCron Table Entry SyntaxWildcardsat CommandOutput ControlSilent RunningUsing getopts to Parse Command-Line ArgumentsMaking a Co-Process with Background FunctionCatching a Delayed Command OutputFastest Ways to Process a File Line -by LineMail Notification TechniquesUsing the mail and mailx CommandsUsing the sendmail Command to Send Outbound MailCreating a Progress IndicatorA Series of DotsA Rotating LineCreating a Psuedo-Random NumberChecking for Stale Disk Partitions in AIXAutomated Host PingingHighlighting Specific Text in a FileKeeping the Printers PrintingAIX “Classic” Printer SubsystemSystem V PrintingAutomated FTP File TransferCapturing a List of Files Larger than MEGCapturing a User’s KeystrokesUsing the bc Utility for Floating-Point MathNumber Base ConversionsUsing the typeset CommandUsing the printf CommandCreate a Menu with the select CommandSending Pop-Up Messages to WindowsRemoving Repeated Lines in a FileRemoving Blank Lines from a 343434353535363737383838393939404041414142434344

ContentsTesting for a Null VariableDirectly Access the Value of the Last Positional Parameter, #Remove the Columns Heading in a Command OutputArraysLoading an ArrayChapter 24751Twelve Ways to Process a File Line by LineCommand Syntax5353Twelve Methods to Parse a File Line by LineMethod 1: cat FILENAME while read LINEMethod 2: while read FILENAME from BottomMethod 3: while line LINE BottomMethod 4: cat FILENAME while LINE line Method 5: cat FILENAME while line LINEMethod 6: while LINE line from the BottomMethod 7: cat FILENAME while LINE (line)Method 8: while LINE (line) from the BottomMethod 9: while read LINE Using File DescriptorsMethod 10: while LINE ’line’ Using File DescriptorsMethod 11: while LINE (line) Using File DescriptorsMethod 12: while line LINE Using File DescriptorsTiming Each MethodTiming ScriptTiming Data for Each MethodTiming Command Substitution ed Event NotificationBasics of Automating Event Notification7979Using the mail and mailx CommandsCreate a “Bounce” Account with a .forward FileUsing the sendmail Command to Send Outbound MailFree & Share & Open5454SummaryProblems with Outbound MailChapter 446Testing a StringSummaryUsing File DescriptorsCreating a Large File to Use in the Timing TestChapter 34445454680828283Dial-Out Modem SoftwareSNMP TrapsSummary848586Progress Indicator Using a Series of Dots,a Rotating Line, or a Countdown to ZeroIndicating Progress with a Series of DotsIndicating Progress with a Rotating LineCreating a Countdown IndicatorOther Options to ConsiderSummary878789919596xi

xiiContentsChapter 5File System MonitoringSyntaxAdding Exceptions Capability to MonitoringThe Exceptions FileUsing the MB of Free Space MethodUsing MB of Free Space with ExceptionsPercentage Used—MB Free and Large FilesystemsRunning on AIX, Linux, HP-UX, and SolarisCommand Syntax and Output Varies betweenOperating SystemsOther Options to ConsiderEvent NotificationAutomated ExecutionModify the egrep StatementChapter g Paging and Swap SpaceSyntax145146AIX lsps CommandHP-UX swapinfo CommandLinux free CommandSolaris swap CommandCreating the Shell ScriptsAIX Paging MonitorHP-UX Swap Space MonitorLinux Swap Space MonitorSolaris Swap Space MonitorAll-in-One Paging and Swap Space MonitorChapter 79798103146147148148149149155160164169Other Options to Consider176Event NotificationLog FileScheduled Monitoring177177177Summary177Monitoring System LoadSyntax179180Syntax for uptimeAIXHP-UXLinuxSolarisWhat Is the Common Denominator?Scripting an uptime Field Test SolutionSyntax for iostatAIXHP-UX180180181182183183184186186186

ContentsLinuxSolarisWhat Is the Common Denominator?Syntax for sarAIXHP-UXLinuxSolarisWhat Is the Common Denominator?Syntax for vmstatAIXHP-UXLinuxSolarisWhat Is the Common Denominator?Scripting the SolutionsUsing uptime to Measure the System LoadScripting with the uptime CommandUsing sar to Measure the System LoadScripting with the sar CommandUsing iostat to Measure the System LoadScripting with the iostat CommandUsing vmstat to Measure the System LoadScripting with the vmstat CommandOther Options to ConsiderStop Chasing the Floating uptime FieldTry to Detect Any Possible Problems for the UserShow the User the Top CPU HogsGathering a Large Amount of Data for PlottingSummaryChapter 8Process Monitoring and Enabling Preprocess, Startup,and Postprocess EventsSyntaxMonitoring for a Process to StartMonitoring for a Process to EndMonitor and Log as a Process Starts and StopsTimed Execution for Process Monitoring, Showing each PID,and Time Stamp with Event and Timing CapabilityOther Options to ConsiderCommon UsesModifications to ConsiderChapter 9Free & Share & 216218223228248248248Summary249Monitoring Processes and ApplicationsMonitoring Local ProcessesRemote Monitoring with Secure Shell251252254Checking for Active Oracle DatabasesChecking If the HTTP Server/Application Is Working256259xiii

xivContentsOther Things to ConsiderApplication APIs and SNMP TrapsSummary260261261Chapter 10 Creating Pseudo-Random PasswordsRandomnessCreating Pseudo-Random PasswordsSyntax263263264264ArraysLoading an Array265265Building the Password Creation ScriptOrder of AppearanceDefine VariablesDefine FunctionsTesting and Parsing Command-Line ArgumentsBeginning of MainSetting a TrapChecking for the Keyboard FileLoading the “KEYS” ArrayUsing the LENGTH Variable to Build a Loop ListBuilding a New Pseudo-Random PasswordPrinting the Manager’s Password Report for Safe KeepingOther Options to ConsiderPassword Reports?Which Password?Other Uses?SummaryChapter 11 Monitor for Stale Disk PartitionsAIX Logical Volume Manager (LVM)The Commands and MethodsDisk Subsystem CommandsMethod 1: Monitoring for Stale PPs at the LV LevelMethod 2: Monitoring for Stale PPs at the PV LevelMethod 3: VG, LV, and PV Monitoring with a 5295295297298298298299304308Other Options to Consider315SSA DisksLog FilesAutomated ExecutionEvent Notification315316316316SummaryChapter 12 Automated Hosts Pinging with NotificationSyntaxCreating the Shell ScriptDefine the VariablesCreating a TrapThe Whole Shell Script317319320321321323324

ContentsOther Options to Consider PINGLIST Variable Length Limit ProblemPing the /etc/hosts File Instead of a List FileLoggingNotification of “Unknown host”Notification MethodAutomated Execution Using a Cron Table EntrySummary332332333333334334335335Chapter 13 Taking a System SnapshotSyntaxCreating the Shell ScriptOther Options to ConsiderSummary337338340367367Chapter 14 Compiling, Installing, Configuring, and Using sudoThe Need for sudoDownloading and Compiling sudoCompiling sudoConfiguring sudoUsing sudoUsing sudo in a Shell ScriptThe sudo Log FileSummary369369370371378384385389390Chapter 15 hgrep: Highlighted grep ScriptReverse Video ControlBuilding the hgrep.ksh Shell ScriptOther Options to Consider391392393400Other Options for the tput CommandSummaryChapter 16 Print Queue Hell: Keeping the Printers PrintingSystem V versus BSD Printer SubsystemsFree & Share & OpenAIX Print Control CommandsClassic AIX Printer SubsystemSystem V Printing on AIXMore System V Printer CommandsHP-UX Print Control CommandsLinux Print Control CommandsControlling Queuing and Printing IndividuallySolaris Print Control CommandsMore System V Printer ting It All TogetherOther Options to Consider431438LoggingExceptions 439xv

xviContentsChapter 17 Automated FTP StuffSyntaxAutomating File Transfers and Remote Directory ListingsUsing FTP for Directory Listings on a Remote MachineGetting One or More Files from a Remote SystemPre and Post EventsScript in ActionPutting One or More Files to a Remote SystemReplacing Hard-Coded Passwords with VariablesExample of Detecting Variables in a Script’s EnvironmentModifying Our FTP Scripts to Use Password VariablesOther Options to ConsiderUse Command-Line Switches to Control ExecutionKeep a Log of ActivityAdd a Debug Mode to the 463463463464Chapter 18 Finding “Large” FilesSyntaxCreating the ScriptOther Options to ConsiderSummary465466466472473Chapter 19 Monitoring and Auditing User Key StrokesSyntaxScripting the Solution475476477Logging User ActivityStarting the Monitoring SessionWhere Is the Repository?The ScriptsLogging root ActivitySome sudo StuffMonitoring Other Administration Users478479479480483486489Other Options to Consider492Emailing the Audit LogsCompressionNeed Better Security?Inform the UsersSudoers File493493493493494SummaryChapter 20 Turning On/Off SSA Identification LightsSyntaxTranslating an hdisk to a pdiskIdentifying an SSA DiskThe Scripting ProcessUsage and User Feedback FunctionsControl FunctionsThe Full Shell Script494495496496496497497501507

ContentsOther Things to Consider520Error LogCross-ReferenceRoot Access and sudo520520520SummaryChapter 21 Pseudo-Random Number GenerationWhat Makes a Random Number?The MethodsMethod 1: Creating Numbers between 0 and 32,767Method 2: Creating Numbers between 1 and aUser-Defined MaximumMethod 3: Fixed-Length Numbers between 1 and aUser-Defined MaximumWhy Pad the Number with Zeros the Hard Way?Shell Script to Create Pseudo-Random NumbersCreating Unique FilenamesSummaryChapter 22 Floating-Point Math and the bc UtilitySyntaxCreating Some Shell Scripts Using bcCreating the float add.ksh Shell ScriptTesting for Integers and Floating-Point NumbersBuilding a Math Statement for the bc CommandUsing a Here DocumentCreating the float subtract.ksh Shell ScriptUsing getopts to Parse the Command LineBuilding a Math Statement String for bcHere Document and Presenting the ResultCreating the float multiply.ksh Shell ScriptParsing the Command Line for Valid NumbersCreating the float divide.ksh Shell ScriptCreating the float average.ksh Shell ScriptOther Options to ConsiderRemove the Scale from Some of the Shell ScriptsCreate More FunctionsSummaryChapter 23 Scripts for Number Base ConversionsSyntaxFree & Share & OpenExample 23.1: Converting from Base 10 to Base 16Example 23.2: Converting from Base 8 to Base 16Example 23.3 Converting Base 10 to OctalExample 23.4 Converting Base 10 to HexadecimalScripting the SolutionBase 2 (binary) to Base 16 (hexadecimal) Shell ScriptBase 10 (Decimal) to Base 16 (Hexadecimal) Shell 85586586587587587587590xvii

xviii ContentsScript to Create a Software Key Based on the HexadecimalRepresentation of an IP AddressScript to Translate between Any Number BaseUsing getopts to Parse the Command LineExample 23.5 Correct Usage of the Equate any base.kshShell ScriptExample 23.6 Incorrect Usage of the Equate any base.kshShell ScriptContinuing with the ScriptBeginning of MainOther Options to ConsiderSoftware Key Shell ScriptSummaryChapter 24 Menu Program Suitable for Operations StaffReverse Video SyntaxCreating the MenuCreating a Message Bar for FeedbackFrom the TopOther Options to ConsiderShelling Out to the Command LineGood Candidate for Using sudoSummaryChapter 25 Sending Pop-Up Messages from Unix to WindowsAbout Samba and the smbclient CommandSyntaxBuilding the broadcast.ksh Shell ScriptSending a Message to All UsersAdding Groups to the Basic CodeAdding the Ability to Specify Destinations IndividuallyUsing getopts to Parse the Command LineTesting User InputTesting and Prompting for WINLIST DataTesting and Prompting for Message DataSending the MessagePutting It All TogetherWatching the broadcast.ksh Script in ActionDownloading and Installing SambaTesting the smbclient Program the First TimeOther Options to ConsiderProducing Error NotificationsAdd Logging of Unreachable MachinesCreate Two-Way 629630640642643644645645645Summary645Appendix A What’s on the Web Site647Index663

IntroductionIn Unix there are many ways to accomplish a given task. Given a problem to solve, wemay be able to get to a solution in any number of ways. Of course, some will be moreefficient, be more readable, use less disk space or memory, may or may not give the userfeedback on what is going on or give more accurate details and more precision to theresult. In this book we are going to step through every detail of writing a shell script tosolve real-world Unix problems and tasks. The shell scripts range from using a pseudorandom number generator to create pseudo-random passwords to checking for fullfilesystems on Unix machines and to sending pop-up messages to Windows desktops.The details required to write these shell scripts include using good style and providinggood comments throughout the shell script by describing each step. Other details includecombining many commands into just one command statement when desirable, separating commands on several lines when readability and understanding of the concept maybe diminished, and making a script readable and easy to maintain. We will see the benefit of using variables and files to store data, show methods to strip out unwanted orunneeded data from a command output, and format the data for a particular use. Additionally, we are going to show how to write and include functions in our shell scripts anddemonstrate the benefits of functions over a shell script written without functions.This book is intended for any flavor of Unix, but its emphasis includes AIX, Linux,HP-UX, and Solaris operating systems. Most every script in the book is also included onthe book’s companion Web site (www.wiley.com/compbooks/michael). Many of the shellscripts are rewritten for each different operating system, when it is necessary. Other shellscripts are not platform dependent. These script rewrites are sometimes needed becausecommand syntax and output vary, sometimes in a major way, between Unix flavors. Thevariations are sometimes as small as pulling the data out of a different column or using adifferent command switch, or they can be as major as putting several commands togetherto accomplish the same task to get similar output or result on different flavors of Unix.In each chapter we start with the very basic concepts and work our way up to somevery complex and difficult concepts. The primary purpose of a shell script is automatingrepetitive and complex functions. This alleviates keystroke errors and allows for timescheduled execution of the shell script. It is always better to have the system tell us thatFree & Share & Openxix

xxIntroductionit has a problem than to find out too late to be proactive. This book will help us to be moreproactive in our dealings with the system. At every level we will gain more knowledgeto allow us to move on to ever increasingly complex ideas with ease. We are going toshow different ways to solve our real-world example tasks. There is not just one correctway to solve a challenge, and we are going to look at the pros and cons of attacking aproblem in various ways. Our goal is to be confident and flexible problem solvers. Givena task, we can solve it in any number of ways, and the solution will be intuitively obvious when you complete this book.Overview of the Book and TechnologyThis book is intended as a learning tool and study guide to learn how to write shellscripts to solve a multitude of problems by starting with a clear goal. While studyingwith this book we will cover most shell scripting techniques about seven times, eachtime from a different angle, solving a different problem. I have found this learningtechnique to work extremely well for retention of the material to memory.I urge everyone to read this book from cover to cover to get the maximum benefit.Every script is written using Korn shell, which is the industry standard for scriptingsolutions in Unix, although some may argue this point. There are several versions ofthe Korn shell shipped with Unix, depending on the Unix operating system (OS) andthe version of the OS release. I have found that the shell scripts in this book will run onany of the Korn shell versions without any modification.This book goes from some trivial task solutions to some rather advanced conceptsthat Systems Administrators will benefit from, and a lot of stuff in between. There areseveral chapters for each level of complexity scattered throughout this book. The shellscripts presented in this book are complete shell scripts, which is one of the things thatsets this book apart from other shell scripting books on the market. The solutions areexplained thoroughly, with each part of the shell script explained in minute detaildown to the philosophy and mindset of the author.How This Book Is OrganizedEach chapter starts with a typical Unix challenge that occurs every day in the computing world. With each challenge we define a specific goal and start the shell script bydefining the correct command syntax to solve the problem. When we have a goal andthe command syntax, we start building the shell script around the commands. The nextstep is to filter the command(s) output to strip out the unneeded data, or we maydecide to just extract the data we need from the output. If the syntax varies betweenUnix flavors we show the correct syntax to get the same, or a similar, result. When weget to this point we go further to build options into the shell script to give the end usermore flexibility on the command line.When a shell script has to be rewritten for each operating system, a combined shellscript is shown at the end of the chapter that joins the Unix flavor differences togetherinto one shell script that will run on all of the OS flavors. To do this last step we querythe system for the Unix flavor using the uname command. By knowing the flavor ofthe operating system we are able to execute the proper commands for each Unix flavor

Introductionby using a simple case statement. If this is new to you, do not worry; everything isexplained throughout the book in detail.Each chapter targets a different real-world problem. Some challenges are very complex, while others are just interesting to play around with. Some chapters hit the problem from several different angles in a single chapter, and others leave you the challengeto solve on your own—of course, with a few hints to get you started. Each chaptersolves the challenge presented and can be read as a single unit without referencingother chapters in the book. Some of the material, though, is explained in great detail inone chapter and lightly covered in other chapters. Because of this variation we recommend that you start at the beginning of the book and read and study every chapter tothe end of the book because this is a learning experience!Who Should Read This BookThis book is intended for anyone who works with Unix on a daily basis from thecommand line. The topics studied in the book are mainly for Unix professionals—Programmers, Programmer-Analysts, System Operators, Systems Administrators, andanyone who is interested in getting ahead in the support arena. Beginners will get a lotout of this book, too, but some of the material may be a little high level, so a basic Unixbook may be needed to answer some questions. Everyone should have a good working knowledge of common Unix commands before starting this book, because we donot explain common Unix commands at all.I started my career in Unix by learning on the job how to be a Systems Operator. Iwish I had a book like this when I started. Having this history I wanted others to get ajump start on their careers. I wrote this book with the knowledge that I was in yourshoes at one time, and I remember that I had to learn everything from the man pages,one command at a time. Use this book as a study guide, and you will have a jump startto get ahead quickly in the Unix world, which is getting bigger all of the time.Tools You Will NeedTo get the most benefit from this book you need access to a Unix machine, preferablywith AIX, HP-UX, Linux, or Solaris installed. You can run Linux and Solaris on standard PC hardware, and it is relatively inexpensive. It is a good idea to make yourdefault shell environment the Korn shell (ksh); the standard shell on Linux is theBourne Again shell (bash) shell, and some others use Bourne shell (sh) as the default.You can find your default shell by entering echo SHELL from the command line.None of the shell scripts in this book requires a graphical terminal, but it sure does nothurt to have GNOME, CDE, KDE2, or X-Windows running. This way you can work inmultiple windows at the same time and cut and paste code between windows.You also need a text editor that you are comfortable using. Most Unix operating systems come with the vi editor, and a lot also include emacs. Remember that the editormust be a text editor that stores files in a standard ANSII format. The CDE and otherX-editors work just fine, too. You will also need some time, patience, and an open,creative mind that is ready to learn.Free & Share & Openxxi

xxiiIntroductionAnother thing to note is that all of the variables used in the shell scripts and functions in this book are in uppercase. I did this because it is much easier to follow alongwith a shell script if you know quickly where the variables are located in the code.When you write your own shell scripts, please use lowercase for all shell script andfunction variables. The reason this is important is that the operating system, and applications, use environment variables that are in uppercase. If you are not careful, you canoverwrite a critical system or application variable with your own value and hose upthe system; however this is dependent on the scope of where the variable is visible inthe code. Just a word of warning, be careful with uppercase variables!What’s on the Web SiteOn the book’s companion Web site, www.wiley.com/compbooks/michael, all of theshell scripts and most of the functions that are studied in the book can be found. Thefunctions are easy to cut and paste directly into your own shell scripts to make thescripting process a little easier. Additionally, there is a shell script stub that you cancopy to another filename. This script stub has everything to get you started writingquickly. The only thing you need to do is fill in the fields for the following: ScriptName, Author, Date, Version, Platform, Purpose, and Rev List, when revisions aremade. There is a place to define variables and functions, and then you have a“BEGINNNG OF MAIN” section to start the main body of the shell script.SummaryThis book is for learning how to be creative, proactive, and a professional problemsolver. Given a task, the solution will be intuitively obvious to you on completion of thisbook. This book will help you attack problems logically and present you with a technique of building on what you know. With each challenge presented you will see howto take the basic syntax and turn it into the basis for a shell scripting solution. Wealways start with the basics and build more and more logic into the solution before weadd other options the end user can use for more flexibility.Speaking of end users, we must always keep our users informed about how processing is progressing. Giving a user a blank screen to look at is the worst thing thatyou can do, so for this we can create progress indicators. You will learn how to beproactive by building tools that monitor for specific situations that indicate the beginning stages of an upcoming problem. This is where knowing how to query the systemputs you ahead of the rest of your staff.With the techniques presented in this book, you will learn. You will learn aboutproblem resolution. You will learn about starting with what you know about a s

UNIX details on almost a weekly basis, I doubt this book would have ever been writ-ten. So, thanks Jim! I especially want to thank Jack Renfro at Daimler/Chrysler Corporation for giving me my first shell scripting project so long ago. I had to start with the man pages