Daniel Seix
4/23/2006 9:17:00 AM
JoeKarma@gmail.com escribió:
> Hi,
>
> I'm interested in automating user input at the command line.
> Specifically, I'd like to "cheat" in a text based adventure game
> (dunnet for emacs). I'm a complete novice, and although I'm sure this
> is possible, I'd appreciate suggestions as to where I should learn how.
>
> It's not that I'd like to skip the basics, but rather I learn best by
> doing - and I do enjoy the gratification culled from a marginally
> useful toy program.
>
> Thanks!
If on UNIX and with PTY98 support, this is a starting point:
#!/usr/bin/env ruby
require 'pty'
require 'expect'
$expect_verbose = true
help_msg = ""
PTY.spawn("emacs -batch -l dunnet") do |reader, writer, pid|
reader.expect('>')
writer.puts('help')
begin c = reader.getc.chr
help_msg << c
end while c != '>'
writer.puts('quit')
end
puts "This is the help message: #{help_msg}"