From 523e68c9b3a387d8c3d2b7c4278ea4aab1e8b040 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Feb 2016 11:31:44 -0800 Subject: Opscode -> Chef --- mixlib-shellout.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mixlib-shellout.gemspec b/mixlib-shellout.gemspec index e406c74..37b7cf2 100644 --- a/mixlib-shellout.gemspec +++ b/mixlib-shellout.gemspec @@ -8,9 +8,9 @@ Gem::Specification.new do |s| s.extra_rdoc_files = ["README.md", "LICENSE" ] s.summary = "Run external commands on Unix or Windows" s.description = s.summary - s.author = "Opscode" - s.email = "info@opscode.com" - s.homepage = "http://wiki.opscode.com/" + s.author = "Chef Software Inc." + s.email = "info@chef.io" + s.homepage = "https://www.chef.io/" s.required_ruby_version = ">= 1.9.3" -- cgit v1.2.1 From bc7db8ef40b5aa729c5da139e61eb502e49fd780 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Feb 2016 11:32:39 -0800 Subject: Format markdown for better rendering Also add the require to the example and fix an awkward sentence --- README.md | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 2cfe5b0..51a0e81 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,66 @@ # Mixlib::ShellOut -Provides a simplified interface to shelling out yet still collecting both -standard out and standard error and providing full control over environment, -working directory, uid, gid, etc. +Provides a simplified interface to shelling out while still collecting both standard out and standard error and providing full control over environment, 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 +```ruby + require 'mixlib/shellout' + find = Mixlib::ShellOut.new("find . -name '*.rb'") + find.run_command +``` If all went well, the results are on `stdout` - puts find.stdout +```ruby + puts find.stdout +``` `find(1)` prints diagnostic info to STDERR: - puts "error messages" + find.stderr +```ruby + puts "error messages" + find.stderr +``` Raise an exception if it didn't exit with 0 - find.error! +```ruby + 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. +```ruby + 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 +```ruby + # :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 +``` ## Windows Impersonation Example Invoke "whoami.exe" to demonstrate running a command as another user: - whoami = Mixlib::ShellOut.new("whoami.exe", :user => "username", :domain => "DOMAIN", :password => "password") - whoami.run_command +```ruby + whoami = Mixlib::ShellOut.new("whoami.exe", :user => "username", :domain => "DOMAIN", :password => "password") + whoami.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. +Mixlib::ShellOut does a standard fork/exec on Unix, and uses the Win32 API on Windows. There is not currently support for JRuby. ## License Apache 2 Licensed. See LICENSE for full details. ## See Also -* `Process.spawn` in Ruby 1.9 -* [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn) +- `Process.spawn` in Ruby 1.9 +- [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn) -- cgit v1.2.1 From c2636cafe085582a3c9d82c7db88fcedf119ff93 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Feb 2016 11:41:51 -0800 Subject: Expand the license section --- README.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 51a0e81..d137035 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,25 @@ Invoke "whoami.exe" to demonstrate running a command as another user: ## 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. -## License -Apache 2 Licensed. See LICENSE for full details. - ## See Also - `Process.spawn` in Ruby 1.9 - [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn) + +# LICENSE: + +* Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. +* License:: Apache License, Version 2.0 + +```text +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` -- cgit v1.2.1 From 78613575606febfd68e315be7b71d2be77385f16 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Feb 2016 11:42:25 -0800 Subject: Update travis config Test on Ruby 2.2 Run in the container environment Cache gems --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 39aa782..102f660 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,13 @@ +language: ruby +cache: bundler + +sudo: false + rvm: - 1.9.3 - 2.0.0 - 2.1.2 + - 2.2 before_install: - gem update bundler -- cgit v1.2.1 From bf9f1dfe5ec7ec032b111aa6bd9272db7067f654 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Feb 2016 11:46:29 -0800 Subject: opscode -> Chef --- lib/mixlib/shellout.rb | 4 ++-- lib/mixlib/shellout/unix.rb | 4 ++-- lib/mixlib/shellout/windows.rb | 8 ++++---- lib/mixlib/shellout/windows/core_ext.rb | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb index 6f8730f..2fdbcfd 100644 --- a/lib/mixlib/shellout.rb +++ b/lib/mixlib/shellout.rb @@ -1,6 +1,6 @@ #-- -# Author:: Daniel DeLeo () -# Copyright:: Copyright (c) 2010, 2011 Opscode, Inc. +# Author:: Daniel DeLeo () +# Copyright:: Copyright (c) 2010-2016 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb index dd22cbe..734a597 100644 --- a/lib/mixlib/shellout/unix.rb +++ b/lib/mixlib/shellout/unix.rb @@ -1,6 +1,6 @@ #-- -# Author:: Daniel DeLeo () -# Copyright:: Copyright (c) 2010, 2011 Opscode, Inc. +# Author:: Daniel DeLeo () +# Copyright:: Copyright (c) 2010-2016 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb index 14aca55..fd8039b 100644 --- a/lib/mixlib/shellout/windows.rb +++ b/lib/mixlib/shellout/windows.rb @@ -1,8 +1,8 @@ #-- -# Author:: Daniel DeLeo () -# Author:: John Keiser () -# Author:: Ho-Sheng Hsiao () -# Copyright:: Copyright (c) 2011, 2012 Opscode, Inc. +# Author:: Daniel DeLeo () +# Author:: John Keiser () +# Author:: Ho-Sheng Hsiao () +# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/mixlib/shellout/windows/core_ext.rb b/lib/mixlib/shellout/windows/core_ext.rb index ab54a9e..2fe2bf2 100644 --- a/lib/mixlib/shellout/windows/core_ext.rb +++ b/lib/mixlib/shellout/windows/core_ext.rb @@ -1,7 +1,7 @@ #-- -# Author:: Daniel DeLeo () -# Author:: John Keiser () -# Copyright:: Copyright (c) 2011, 2012 Opscode, Inc. +# Author:: Daniel DeLeo () +# Author:: John Keiser () +# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -268,8 +268,8 @@ module Process # If running in the service windows station must do a log on to get # to the interactive desktop. Running process user account must have # the 'Replace a process level token' permission. This is necessary as - # the logon (which happens with CreateProcessWithLogon) must have an - # interactive windows station to attach to, which is created with the + # the logon (which happens with CreateProcessWithLogon) must have an + # interactive windows station to attach to, which is created with the # LogonUser cann with the LOGON32_LOGON_INTERACTIVE flag. if winsta_name =~ /^Service-0x0-.*$/i token = FFI::MemoryPointer.new(:ulong) -- cgit v1.2.1 From 433dbde306689399be44bae3b225e9ff53bdd5ee Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Feb 2016 12:04:11 -0800 Subject: Add badges to the readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d137035..7f463e0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # Mixlib::ShellOut +[![Build Status Master](https://travis-ci.org/chef/mixlib-shellout.svg?branch=master)](https://travis-ci.org/chef/mixlib-shellout) +[![Build Status Master](https://ci.appveyor.com/api/projects/status/github/chef/mixlib-shellout?branch=master&svg=true&passingText=master%20-%20Ok&pendingText=master%20-%20Pending&failingText=master%20-%20Failing)](https://ci.appveyor.com/project/Chef/mixlib-shellout/branch/master) +[![Gem Version](https://badge.fury.io/rb/mixlib-shellout.svg)](https://badge.fury.io/rb/mixlib-shellout) + Provides a simplified interface to shelling out while still collecting both standard out and standard error and providing full control over environment, working directory, uid, gid, etc. No means for passing input to the subprocess is provided. @@ -62,7 +66,7 @@ Mixlib::ShellOut does a standard fork/exec on Unix, and uses the Win32 API on Wi - `Process.spawn` in Ruby 1.9 - [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn) -# LICENSE: +## License * Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. * License:: Apache License, Version 2.0 -- cgit v1.2.1 From ba59f99026ce412b52ba18c83675710a50a7fd5b Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Feb 2016 12:17:06 -0800 Subject: Document more advanced usage Fix badge and some formatting as well --- README.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7f463e0..4a9bf34 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # Mixlib::ShellOut -[![Build Status Master](https://travis-ci.org/chef/mixlib-shellout.svg?branch=master)](https://travis-ci.org/chef/mixlib-shellout) -[![Build Status Master](https://ci.appveyor.com/api/projects/status/github/chef/mixlib-shellout?branch=master&svg=true&passingText=master%20-%20Ok&pendingText=master%20-%20Pending&failingText=master%20-%20Failing)](https://ci.appveyor.com/project/Chef/mixlib-shellout/branch/master) -[![Gem Version](https://badge.fury.io/rb/mixlib-shellout.svg)](https://badge.fury.io/rb/mixlib-shellout) +[![Build Status Master](https://travis-ci.org/chef/mixlib-shellout.svg?branch=master)](https://travis-ci.org/chef/mixlib-shellout) [![Build Status Master](https://ci.appveyor.com/api/projects/status/github/chef/mixlib-shellout?branch=master&svg=true&passingText=master%20-%20Ok&pendingText=master%20-%20Pending&failingText=master%20-%20Failing)](https://ci.appveyor.com/project/Chef/mixlib-shellout/branch/master) [![Gem Version](https://badge.fury.io/rb/mixlib-shellout.svg)](https://badge.fury.io/rb/mixlib-shellout) Provides a simplified interface to shelling out while still collecting both standard out and standard error and providing full control over environment, working directory, uid, gid, etc. No means for passing input to the subprocess is provided. ## Example +### Simple Shellout Invoke find(1) to search for .rb files: ```ruby @@ -34,14 +33,21 @@ 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` +### Advanced Shellout +In addition to the command to run there are other attributes that can be set to change the shellout behavior: +- `env`: set environmental variables before shelling out +- `user`: execute the shellout as this user +- `cwd`: execute the shellout from this directory +- `timeout`: set a command timeout (defaul 600s) + +Run a command as the `www` user with no extra ENV settings from `/tmp` with a 1s timeout ```ruby - cmd = Mixlib::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp') + cmd = Mixlib::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp', :timeout => 1) cmd.run_command # etc. ``` -## STDIN Example +### STDIN Example Invoke crontab to edit user cron: ```ruby @@ -51,7 +57,7 @@ Invoke crontab to edit user cron: crontab.run_command ``` -## Windows Impersonation Example +### Windows Impersonation Example Invoke "whoami.exe" to demonstrate running a command as another user: ```ruby @@ -67,9 +73,8 @@ Mixlib::ShellOut does a standard fork/exec on Unix, and uses the Win32 API on Wi - [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn) ## License - -* Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. -* License:: Apache License, Version 2.0 +- Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. +- License:: Apache License, Version 2.0 ```text Licensed under the Apache License, Version 2.0 (the "License"); -- cgit v1.2.1 From f47333b6969a744d64f01a3533fd9faff7e6b1bb Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 17 Feb 2016 14:48:12 -0800 Subject: Link to the code for the complete list Technically I could type this all, but it's probably easier to just link direct to the options --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 4a9bf34..85146d8 100644 --- a/README.md +++ b/README.md @@ -34,11 +34,7 @@ Raise an exception if it didn't exit with 0 ``` ### Advanced Shellout -In addition to the command to run there are other attributes that can be set to change the shellout behavior: -- `env`: set environmental variables before shelling out -- `user`: execute the shellout as this user -- `cwd`: execute the shellout from this directory -- `timeout`: set a command timeout (defaul 600s) +In addition to the command to run there are other options that can be set to change the shellout behavior. The complete list of options can be found here: https://github.com/chef/mixlib-shellout/blob/master/lib/mixlib/shellout.rb Run a command as the `www` user with no extra ENV settings from `/tmp` with a 1s timeout -- cgit v1.2.1 From 0bdcd675a3d7469566ecd0a4d2d307549ac15f8f Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 2 Mar 2016 10:03:48 -0800 Subject: Update ruby versions to test on --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 102f660..82e236e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,11 @@ cache: bundler sudo: false rvm: - - 1.9.3 - - 2.0.0 - - 2.1.2 + - 2.0 + - 2.1 - 2.2 + - 2.3 + before_install: - gem update bundler -- cgit v1.2.1 From 3a8640ad0c1b080d0acd491ae29d019b00e9ab34 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 2 Mar 2016 12:43:47 -0800 Subject: 2.3 is not yet known by RVM so use 2.3.0 See https://github.com/travis-ci/travis-ci/issues/5361 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 82e236e..532f415 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ rvm: - 2.0 - 2.1 - 2.2 - - 2.3 + - 2.3.0 before_install: - gem update bundler -- cgit v1.2.1