 
 This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
| Capturing the Output and Error Streams from a Unix Shell Command | ||
|---|---|---|
| Code | Expected | Actual | 
| %x{ls no_such_directory} | ls: no_such_directory: No such file or directory | |
| require 'open3'
Open3.popen3('ls -l no_such_directory') { |stdin, stdout, stderr| stderr.read } | "ls: no_such_directory: No such file or directory\n" | "ls: no_such_directory: No such file or directory\n" |