#!/usr/bin/ruby require "io/console" a = [] if STDIN.isatty print "Reading 5 keys from console\n" 5.times{ k = STDIN.getch a.push(k) } else print "Reading characters from pipe\n" #STDIN.each_char{|k| # a.push(k) #} bytes = STDIN.read while bytes.length > 0 a.push(bytes[0]) bytes = bytes[1, bytes.length - 1] end end print a, "\n"