ruby-ssh 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a172d5fc2c7f0b5eab3fa3734969e559365df99
4
- data.tar.gz: 7c9215c7d28ed95f08d588074b7e596f720d1eb5
3
+ metadata.gz: fc1b30ccddcfdcda575eea429d00b5a1a1daa4be
4
+ data.tar.gz: b85c0dd34c38f8f8022409b23f7c520bd4f3bd8f
5
5
  SHA512:
6
- metadata.gz: df046a1e9fc56dbbd5909840c746acd00845b074bf0d4deb455fd6d612a60b60a3d63cdb886eb717341bb74feb4502ce18685bcb4fdec699b0d068350d98f6fd
7
- data.tar.gz: ba13de1fff56e8663cf7c5546fcf2026fb80e6fbd5506ca61463a1e31555ef0637cad719b72dab6dc3f975edc5216a9f7a5193702152bfa7f96f07ee1f77ece7
6
+ metadata.gz: ad478fcf9132f55bf96702664265daba15241a4862bf496f1dfec2d31f6236d88b638b1abd79550c6448090a1ffbe2bc174bacc12c1d0ef7b55677cf100399a0
7
+ data.tar.gz: 220054a306d8b16485529b4e594ea7f190cb26fc91bd2c9176eacef1860a07795bde623dbad411817efc72b0983629336c65d3947dc7bd414d665f1711a2c9be
data/README.md CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
  ## Usage
24
24
 
25
25
  ```
26
- Net::SSH.start('ipaddress', 'username', password: 'password') do |ssh|
26
+ RubySSH.start('ipaddress', 'username', password: 'password') do |ssh|
27
27
  ssh.shell_runner do |runner|
28
28
  result = runner.exec('ls -l')
29
29
  puts result.success?
@@ -32,6 +32,10 @@ Net::SSH.start('ipaddress', 'username', password: 'password') do |ssh|
32
32
  end
33
33
  ```
34
34
 
35
+ ```
36
+ RubySSH.start('ipaddress', 'username', password: 'password', script: 'ls ~')
37
+ ```
38
+
35
39
 
36
40
  ## Development
37
41
 
@@ -39,6 +43,14 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
39
43
 
40
44
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
45
 
46
+ ### Debug
47
+
48
+ debug with run rake tasks.
49
+
50
+ $ rake dev:start => perform RubySSH.start
51
+ $ rake dev:run => perform RubySSH.run
52
+
53
+
42
54
  ## Contributing
43
55
 
44
56
  1. Fork it ( https://github.com/[my-github-username]/ruby-ssh/fork )
data/Rakefile CHANGED
@@ -1,2 +1,33 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'ruby-ssh'
2
3
 
4
+ HOST = '192.168.33.11'
5
+ USER = 'root'
6
+ PASSWORD = 'testpass'
7
+
8
+ # for development tasks
9
+ namespace :dev do
10
+ task :start do
11
+ RubySSH.start(HOST, USER, password: PASSWORD) do |ssh|
12
+ ssh.shell_runner do |runner|
13
+ result = runner.exec('ls -l')
14
+ puts result.stdout
15
+ puts result.stderr
16
+ puts result.exit_status
17
+ puts result.success?
18
+ end
19
+ end
20
+ end
21
+
22
+ task :run do
23
+ result = RubySSH.run(HOST, USER, password: 'testpass', script: 'ls')
24
+ puts result.success?
25
+ end
26
+
27
+ task :run_with_key do
28
+ # TODO 失敗時に標準出力がかえらない
29
+ result = RubySSH.run(HOST, 'biscuits_d5df0fdd', keys: ['~/.ssh/biscuits_keys/514bff4fecccf277'], script: 'sudo sshd -T')
30
+ puts result.stdout
31
+ puts result.success?
32
+ end
33
+ end
@@ -1,9 +1,10 @@
1
1
  module RubySSH
2
2
  class Result
3
- attr_reader :stdout, :exit_status
3
+ attr_reader :stdout, :stderr, :exit_status
4
4
 
5
5
  def initialize(args = {})
6
6
  @stdout = args[:stdout]
7
+ @stderr = args[:stderr]
7
8
  @exit_status = args[:exit_status]
8
9
  end
9
10
 
@@ -5,12 +5,16 @@ module RubySSH
5
5
  end
6
6
 
7
7
  def exec(script)
8
- stdout, exit_status = nil
8
+ stdout, stderr, exit_status = nil
9
9
  @session.open_channel do |channel|
10
10
  channel.on_data do |ch, data|
11
11
  stdout = data
12
12
  end
13
13
 
14
+ channel.on_extended_data do |ch, type, data|
15
+ stderr = data
16
+ end
17
+
14
18
  channel.send_channel_request 'shell' do |ch, success|
15
19
  if success
16
20
  ch.send_data(script)
@@ -26,7 +30,7 @@ module RubySSH
26
30
  end
27
31
  end
28
32
  @session.loop
29
- RubySSH::Result.new(stdout: stdout, exit_status: exit_status)
33
+ RubySSH::Result.new(stdout: stdout, stderr: stderr, exit_status: exit_status)
30
34
  end
31
35
  end
32
36
  end
@@ -1,3 +1,3 @@
1
1
  module RubySSH
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - a.harada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh