0.0
No commit activity in last 3 years
No release in over 3 years
A unified interface for running local or remote commands. Provides a dependable & identical response from both types of command.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

< 5, >= 2.6
 Project Readme

Unified interface for ssh or local commands.

Build Status Code Climate

Use

For running local commands it is very much like using the Open3 standard lib, only it returns the same response object as ssh commands.

require 'here_or_there'
include HereOrThere

command = 'whoami'
resp = run_local( command )
resp.stdout
# => "user\n"
resp.stderr
# => ""
resp.success?
# => true

Remote processes are very similar, except that you also pass the information required to establish the remote connection.

require 'here_or_there'
include HereOrThere

command = 'whoami'
resp = run_remote( command, hostname: 'your_remote', username: 'user', password: 'password' )
resp.stdout
# => "user\n"
resp.stderr
# => ""
resp.success?
# => true

# if you have .ssh/config setup, hostname is all that is required

resp = run_remote( command, hostname: 'your_remote' )
resp.stdout
# => "ssh_user\n"
resp.stderr
# => ""
resp.success?
# => true

Response Object

Response objects respond as you expect they would to stdout and stderr giving you those values. It also has a success? method that will retun a bolean of whether the command exited 0 or not.

Ruby Support

Here or There is tested against and supports:

  • 2.0.0
  • 1.9.3
  • rubinius 2.0

If you have experience with and could help out adding jruby support that would be greatly appreciated.

Testing

Tests are run using rspec. Net::SSH sessions are stubbed to prevent needing an actual connection for the suite to run.

$ rspec

Contributing

If there is any thing you'd like to contribute or fix, please:

  • Fork the repo
  • Add tests for any new functionality
  • Make your changes
  • Verify all new & existing tests pass
  • Make a pull request

License

The here_or_there gem is distributed under the MIT License.