- 
      
 - 
        
Save masa16/cd4d88837e97860536244589e9d137d0 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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