Skip to content

Instantly share code, notes, and snippets.

@masa16
Created August 29, 2016 10:41
Show Gist options
  • Save masa16/cd4d88837e97860536244589e9d137d0 to your computer and use it in GitHub Desktop.
Save masa16/cd4d88837e97860536244589e9d137d0 to your computer and use it in GitHub Desktop.
code = 'system gets; puts "end"'
host = "tsukuba100"
cmd = "ssh -x -T #{host} \"ruby -e 'eval ARGF.read(#{code.size})'\""
 
r0,w0 = IO.pipe
r1,w1 = IO.pipe
pid = spawn(cmd,:in=>r0,:out=>w1)
 
w0.write(code)
w0.puts("hostname")
 
while s = r1.gets
break if s.chomp == "end"
puts s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment