Chapter 13. Putting It All Together: Your First Script
IN THIS CHAPTER
You've learned how to use VBScript and several operating system objects; in this chapter, you'll bring together everything you know to design, write, and test an IIS log file rotation tool.
You've already learned just about all the VBScript commands, statements, and functions that you'll need to write administrative scripts. You've learned about some of the built-in scripting objects, and you've had a chance to work with the Windows FileSystemObject. Altogether, that's plenty of information and experience to start writing useful administrative scripts!
In this chapter, you'll design and write a tool that rotates IIS log files. As you probably know, IIS can create a log file for each Web site it operates, and by default, it starts a new log file each day. Your rotation tool will copy the previous day's completed log file to an archival folder for long-term storage. At the same time, the script will delete the oldest log file, keeping a rolling thirty days' worth of log files in the archival folder.
NOTE
To keep things interesting, I'm going to introduce a couple of logic errors into the scripts in this chapter. These scripts should run more or less without error, but they'll have unexpected results due to the way they're written. If you spot the logic errors as you read, great! If not, don't worry-that's what the debugging section of this chapter is for!
|