photocopier 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +9 -9
- data/README.md +2 -2
- data/lib/photocopier/ssh.rb +15 -6
- data/lib/photocopier/version.rb +1 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
photocopier (0.0.
|
4
|
+
photocopier (0.0.5)
|
5
5
|
activesupport
|
6
6
|
escape
|
7
7
|
i18n
|
@@ -12,18 +12,18 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (3.2.
|
15
|
+
activesupport (3.2.12)
|
16
16
|
i18n (~> 0.6)
|
17
17
|
multi_json (~> 1.0)
|
18
18
|
diff-lcs (1.1.3)
|
19
19
|
escape (0.0.4)
|
20
|
-
i18n (0.6.
|
21
|
-
multi_json (1.
|
22
|
-
net-scp (1.0
|
23
|
-
net-ssh (>=
|
24
|
-
net-ssh (2.6.
|
25
|
-
net-ssh-gateway (1.
|
26
|
-
net-ssh (>=
|
20
|
+
i18n (0.6.4)
|
21
|
+
multi_json (1.7.0)
|
22
|
+
net-scp (1.1.0)
|
23
|
+
net-ssh (>= 2.6.5)
|
24
|
+
net-ssh (2.6.6)
|
25
|
+
net-ssh-gateway (1.2.0)
|
26
|
+
net-ssh (>= 2.6.5)
|
27
27
|
rspec (2.11.0)
|
28
28
|
rspec-core (~> 2.11.0)
|
29
29
|
rspec-expectations (~> 2.11.0)
|
data/README.md
CHANGED
@@ -48,8 +48,8 @@ ssh.get_directory('remote_dir', './local_dir')
|
|
48
48
|
# and viceversa
|
49
49
|
ssh.put_directory('./local_dir', 'remote_dir')
|
50
50
|
|
51
|
-
# execs a command and waits for the result, returns
|
52
|
-
ssh.exec!('pwd') # => [ "/home/128423/users/.home\n", 0 ]
|
51
|
+
# execs a command and waits for the result, returns stdout, stderr and exit code
|
52
|
+
ssh.exec!('pwd') # => [ "/home/128423/users/.home\n", "", 0 ]
|
53
53
|
```
|
54
54
|
The very same commands are valid for the `Photocopier::FTP` adapter.
|
55
55
|
|
data/lib/photocopier/ssh.rb
CHANGED
@@ -51,15 +51,24 @@ module Photocopier
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def exec!(cmd)
|
54
|
-
|
54
|
+
stdout = ""
|
55
|
+
stderr = ""
|
55
56
|
exit_code = nil
|
56
|
-
session.
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
session.open_channel do |channel|
|
58
|
+
channel.exec(cmd) do |ch, success|
|
59
|
+
channel.on_data do |ch, data|
|
60
|
+
stdout << data
|
61
|
+
end
|
62
|
+
channel.on_extended_data do |ch, type, data|
|
63
|
+
stderr << data
|
64
|
+
end
|
65
|
+
channel.on_request("exit-status") do |ch, data|
|
66
|
+
exit_code = data.read_long
|
67
|
+
end
|
60
68
|
end
|
61
69
|
end
|
62
|
-
|
70
|
+
session.loop
|
71
|
+
[ stdout, stderr, exit_code ]
|
63
72
|
end
|
64
73
|
|
65
74
|
private
|
data/lib/photocopier/version.rb
CHANGED