summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2011-12-01 14:42:13 -0800
committerDaniel DeLeo <dan@opscode.com>2011-12-01 14:42:13 -0800
commitfe4aea72b34b4e06723f7a422e75fc1c8aa30a90 (patch)
treed536c294f0e1a731c440ea818be49f334a3d0b96 /README.md
parentd051c467ee57f5f633fb3b71a42750c2f40d811d (diff)
downloadmixlib-shellout-fe4aea72b34b4e06723f7a422e75fc1c8aa30a90.tar.gz
add an example to the readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/README.md b/README.md
index 278aa49..88afecd 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,22 @@ working directory, uid, gid, etc.
No means for passing input to the subprocess is provided.
+## Example
+Invoke find(1) to search for .rb files:
+
+ find = Mixlib::ShellOut.new("find . -name '*.rb'")
+ find.run_command
+If all went well, the results are on `stdout`
+ puts find.stdout
+`find(1)` prints diagnostic info to STDERR:
+ puts "error messages" + find.stderr
+Raise an exception if it didn't exit with 0
+ find.error!
+
+Run a command as the `www` user with no extra ENV settings from `/tmp`
+ cmd = Mixlib::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp')
+ cmd.run_command # etc.
+
## Platform Support
Mixlib::ShellOut does a standard fork/exec on Unix, and uses the Win32
API on Windows. There is not currently support for JRuby.