Class: Snapsync::SSHPopenExe
- Inherits:
-
Object
- Object
- Snapsync::SSHPopenExe
show all
- Defined in:
- lib/snapsync/ssh_popen_exe.rb
Defined Under Namespace
Classes: ExitSignal, NonZeroExitCode
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(machine, command, **options) ⇒ SSHPopenExe
Returns a new instance of SSHPopenExe.
20
21
22
23
24
25
26
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 20
def initialize(machine, command, **options)
@err_r, err_w = IO.pipe
full_cmd = ['ssh', machine.uri.host, *command]
Snapsync.debug "Opening SSH Tunnel: #{full_cmd}"
@ssh_proc = IO.popen(full_cmd, err: err_w, mode: 'r+')
end
|
Instance Attribute Details
#read_buffer ⇒ IO
12
13
14
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 12
def read_buffer
@read_buffer
end
|
#ssh_proc ⇒ IO
4
5
6
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 4
def ssh_proc
@ssh_proc
end
|
#write_buffer ⇒ IO
15
16
17
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 15
def write_buffer
@write_buffer
end
|
Instance Method Details
#close ⇒ Object
44
45
46
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 44
def close
ssh_proc.close_write
end
|
#err ⇒ Object
48
49
50
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 48
def err
@err_r.read
end
|
#read(nbytes = nil) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 32
def read(nbytes = nil)
begin
return ssh_proc.read nbytes
rescue Errno::EWOULDBLOCK
return ''
end
end
|
#sync=(sync) ⇒ Object
28
29
30
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 28
def sync=(sync)
end
|
#write(data) ⇒ Object
40
41
42
|
# File 'lib/snapsync/ssh_popen_exe.rb', line 40
def write(data)
ssh_proc.write data
end
|