# -*- encoding: utf-8 -*-

require 'net/telnet'

def get_file_list(address, username, password, dir_path)
  telnet = Net::Telnet.new("Host" => host_address) {|c| print c}
  telnet.login(username, password) {|c| print c}
  telnet.cmd('cd ' + dir_path) {|c| print c}
  telnet.cmd('ls -elR') {|c| print c }
end


# Main
address  = '1.x.xxx.xxx'
dir_path = '/hoge/piyo/FUGA/'
username = 'USERNAME'
password = 'PASSWORD'

get_file_list(address, username, password, dir_path)