SSHã§ã¤ãªãã§ä½ãæä½ãè¡ã£ããããã¹ã¯ã¼ãã®å
¥åãèªååãããã対話形å¼ã®ããã°ã©ã ãããã°ã©ã ä¸ããå©ç¨ããå ´åã¯ãexpectã¢ã¸ã¥ã¼ã«ã使ç¨ããã®ãä¸è¬çã§ãã Rubyã¯æ¨æºã©ã¤ãã©ãªä¸ã«expect.rbãåå¨ãã¦ãã¾ãããIO#exceptã¨ãã¦IOã®ã¡ã½ããã¨ãã¦å®ç¾©ããã¦ãã¦ããã®ã¾ã¾ã§ã¯æ±ãã«ããã®ã§ãä»®æ³ç«¯æ«ãæ±ãPTYã©ã¤ãã©ãªã¨ãããã¦ä½¿ç¨ãã¾ãã require 'pty' require 'expect' module Expect def spawn(cmd) puts "CMD: #{cmd}" if $expect_verbose PTY.spawn(cmd) do |r,w,pid| @input_stream = r @output_stream = w @child_pid = pid PTY.protect_signal do yield en
{{#tags}}- {{label}}
{{/tags}}