Command Line Automation?

J

JoeKarma

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!
 
J

James H.

Hey there!

If I were you I'd start with a tutorial here http://tryruby.hobix.com/
-- it's fully interactive and gets the basics going. Now, as for a
game, you might want to try this tutorial
http://poignantguide.net/ruby/ and work your way up to this one
http://poignantguide.net/dwemthy/ (the last one is a game of sorts).

Now, as for cheating... I'm not entirely sure how Emacs works, but you
might be able to run it from within a script and analyze the output
stream (standard output). It'd take a lot of work, but it could be
fun!

Some other folks here might have better toy program tutorials. Alas, I
do not. If you can, work your way through the basics in some of these
tutorials. I found it quite rewarding.

Best of luck,

James H.
 
D

Daniel Seix

(e-mail address removed) 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}"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,206
Messages
2,571,068
Members
47,674
Latest member
scazeho

Latest Threads

Top