Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

Welcome to ExecuteShell

ExecuteShell provides cross-platform shell command execution. Linux, Windows, and Mac OS X are currently supported. In other words, it lays the smack down like a hungry t-rex in the octagon with a pig.

Getting Started

  1. Install ExecuteShell at the command prompt if you haven't yet:

    $ gem install execute_shell
    
  2. Require the gem in your Gemfile:

    gem 'execute_shell', '~> 1.0.2'
    
  3. Require the gem wherever you need to use it:

    require 'execute_shell'
    

Usage

Simply call ExecuteShell.run as needed:

result = ExecuteShell.run('ls ~')

In this example, result will be a ShellResult object containing information regarding the executed command.

Available methods include:

out ...... Standard out.
err ...... Standard error.
success? . Whether the command was executed successfully.
to_s ..... Standard out and standard error concatenated.

If you wish to simply get a single success, output, or error value back, you may use calls such as:

ExecuteShell.run_success?('ls ~')
ExecuteShell.run_out('ls ~')
ExecuteShell.run_err('ls ~')
ExecuteShell.run_to_s('ls ~')

These may be chained together and will be returned in an array in the order they are specified:

ExecuteShell.run_out_err('ls ~')
ExecuteShell.run_to_s_success_out('ls ~')
ExecuteShell.run_err_out_success('ls ~')

Additional Notes

  • The run method has a second optional parameter, which is a path. If specified, the working directory will be changed to this path prior to executing the shell command. It will be set back to the original working directory before returning to the calling function.

  • Success is based on the content of the err attribute of ShellResult.

Additional Documentation

$ gem install yard
$ yard

Or:

$ rake rdoc:app

License

ExecuteShell is released under the LGPLv3 license.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.