Tuesday, June 28 2005 @ 05:16 AM EDT Contributed by: glosser
It's time for the final installment of the NewsForge's guide to system administration. We brought you part nine last week.
If you're a system administrator, eventually you're going to need to write a shell script. If you're like me and you enjoy scripting, you'll find reasons to write shell scripts for just about everything.
X. Thou shalt not waste time doing repetitive and mundane tasks
hell scripts are nothing more than a semi-sequential list of commands for your shell to run to automate a process that might take you days or weeks to do. This can include sorting syslog entries on a remote logging server, polling your servers for newly available network services, automating your backup policies, creating user accounts, and any other number of tasks. These tasks can be accomplished with any number of different shells, but by far the most common is bash, so that's what we'll focus on here.
I have always believed the best way to learn is by example, so we'll look at an actual shell script to explain some of the fundamentals. In the following example, we're going to take a look at a script I wrote to facilitate packet captures within a a network for visual playback in a program called EtherApe. Don't worry if you don't understand everything in it right away. I'll explain it all in due time.