Net::Telnet を使用して一部のアプライアンスにログインしようとしています。ログイン プロンプトの場合、デバイスは、ログインおよびパスワード プロンプトに対して一度に 1 文字を要求します。Ruby はユーザー名全体を一度に送信します。一度に1文字ずつ送信するように設定する方法はありますか?
これが私のスクリプトです:
require 'net/telnet'
options = Hash.new
ipaddr = '10.160.64.103'
date = Time.new.strftime('-%H.%M.%S')
basedir = '.'
files = Dir.glob("#{ipaddr}*.log")
if files.size >= 0
File.delete(files[0])
end
file = File.new("#{ipaddr}-telnet#{date}.log", "w")
tn = Net::Telnet::new("Host" => ipaddr,
"Output_log" => "#{ipaddr}-telnet#{date}.log",
"Dump_log" => "dump.log",
"Prompt" => /->\z/ )
options["Name"] ||= "anonymous"
options["Password"] ||= "********"
tn.login(options) { |c| print c }
tn.close