Recipe 23.1. Scripting an External Program
Problem
You want to automatically control an external program that expects to get terminal input from a human user.
Solution
When you're running a program that only needs a single strin...
Recipe 23.2. Managing Windows Services
Credit: Bill Froelich
Problem
You want to interact with existing system services on the Windows platform.
Solution
User the win32-service library, available as the gem of the same name. Its Ser...
Recipe 23.3. Running Code as Another User
Problem
While writing a Ruby script that runs as
root, you need to take some action on behalf of another user: say, run an external program or create a file.
Solution
Simply set Process.eu...
Recipe 23.4. Running Periodic Tasks Without cron or at
Problem
You want to write a self-contained Ruby program that performs a task in the background at a certain time, or runs repeatedly at a certain interval.
Solution
Fork off a ne...
Recipe 23.5. Deleting Files That Match a Regular Expression
Credit: Matthew Palmer
Problem
You have a directory full of
files and you need to remove some of them. The patterns you want to match are too complex to represent as file glob...
Recipe 23.6. Renaming Files in Bulk
Problem
You want to rename a bunch of files programmatically: for instance, to normalize the filename case or to change the extensions.
Solution
Use the Find module in the Ruby standard library. He...
Recipe 23.7. Finding Duplicate Files
Problem
You want to find the
duplicate files that are taking up all the space on your hard drive.
Solution
The simple solution is to group the files by size and then by their MD5 checksum. Two ...
Recipe 23.8. Automating Backups
Problem
You want to make a dated archive of a directory to burn to CD or otherwise store on backup media.
Solution
This script copies a directory to a timestamped backup. It reuses the File.versioned_ ...
Recipe 23.9. Normalizing Ownership and Permissions in User Directories
Problem
You want to make make sure your users' home directories don't contain world-writable directories, directories owned by other users, or other potential...
С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.