ruby-ssh 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/Rakefile +31 -0
- data/lib/ruby-ssh/result.rb +2 -1
- data/lib/ruby-ssh/shell_runner.rb +6 -2
- data/lib/ruby-ssh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc1b30ccddcfdcda575eea429d00b5a1a1daa4be
|
4
|
+
data.tar.gz: b85c0dd34c38f8f8022409b23f7c520bd4f3bd8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/ruby-ssh/result.rb
CHANGED
@@ -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
|
data/lib/ruby-ssh/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|