Giter Club home page Giter Club logo

hutte's People

Contributors

bastienleonard avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

hutte's Issues

Support command output capture

Continued from issue #1:

now to figure out how to get the output of "run" commands into variables for processing.
thanks.


Update: scratch all that, use the object that is now returned by local() and run(): https://bastienleonard.github.io/hutte/reference/command_result.html


There isn't a public API for that, but I'll try to add it soon.
In the mean time, if you really need to capture the output of a command, you can use the internal API.
This will be a bit more complicated than necessary because the internal API uses callbacks, so that the output of long-running commands in shown in real time.

For remote commands (self is a Dsl instance, if the block you passed to SshSession.run() takes a parameter, then pass it instead):

Hutte::ssh_exec(self.instance_variable_get('@session'), 'pwd') do |callback|
  callback.on_stdout do |data|
    puts data
  end.on_stderr do |data|
    puts data
  end.on_exit_status_received do |status|
    puts "Exit status: #{status}"
  end
end

For local commands:

status = Hutte::LocalShell.run('pwd') do |callback|
  callback.on_stdout do |data|
    puts data
  end.on_stderr do |data|
    puts data
  end
end

puts "Exit status: #{status}"

Note that you're on your own here, for example Hutte won't raise an error if the command fails (status != 0). Also error checking is minimal, your app will crash if a callback that wasn't supplied gets called.

use .ssh/config

Can hutte be made to use ~/.ssh/config so can specify name that is a "Host" in .ssh/config and it will use the full hostname, port, identityfile etc?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.