Chapter 14. Scripting and System Administration
Programmers often need to "glue" programs together with little scripts that talk to the operating system at a fairly high level and run external programs. This is especially true in the UNIX world, which daily relies on shell scripts for countless tasks.
Ruby is not always a convenient glue language because it is more general-purpose than that. But in the long run, anything that can be done in bash (or the others) can also be done in Ruby.
In many cases, you might just as well use one of the more traditional languages for this purpose. The advantage that Ruby has, of course, is that it really is a general-purpose language, full-featured, and truly object-oriented. On the theory that people might want to use Ruby to talk to the OS at this level, we present here a few tricks that might prove useful.
This chapter was difficult to organize. Much of the functionality could logically be grouped in different ways. If you don't find what you are looking for in the expected place, scan the rest of the chapter also.
In addition, much of what could be covered here is actually dealt with in other chapters entirely. Refer in particular to Chapter 10, "I/O and Data Storage," which covers file I/O and attributes of files; these features are frequently used in scripts of the kind discussed in the present chapter.