summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-30 23:39:10 -0400
committerHo-Sheng Hsiao <hosh@opscode.com>2012-05-10 14:51:43 -0400
commitb9df898902417866409e74d1e6098ca3dbe01f3d (patch)
treeef1d0f41dda212d27a698e2d2bac4cf5967ccefe
parent65440f41e1b20251abbcf65896eb39fa9a157245 (diff)
downloadmixlib-shellout-b9df898902417866409e74d1e6098ca3dbe01f3d.tar.gz
[CHEF-2994][DOC] Add stdin example to README
-rw-r--r--README.md8
1 files changed, 8 insertions, 0 deletions
diff --git a/README.md b/README.md
index e6cdc65..93baa67 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,14 @@ 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.
+## STDIN Example
+Invoke crontab to edit user cron:
+
+ # :input only supports simple strings
+ crontab_lines = [ "* * * * * /bin/true", "* * * * * touch /tmp/here" ]
+ crontab = Mixlib::ShellOut.new("crontab -l -u #{@new_resource.user}", :input => crontab_lines.join("\n"))
+ crontab.run_command
+
## 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.