#!/usr/bin/expect -f # # This is a simple Expect script, based on a script generated by AutoExpect. # Expect is a tool to connect to a server, send a bunch of commands and # wait for expected results. I've modified this script because certain # descriptions may change regularly. I'm sure other things will go wrong # as I use this for later testing. However, this is a good thing to run # to make sure I haven't utterly broken the MUD. With luck I'll keep # generating more of this type of script to do basic testing, so that I # can ensure that a given build of Phantasmal has all commands functioning # correctly before shipping. That will require Expect-fu far beyond my # current level. # # This Expect script was generated by autoexpect on Mon Dec 8 02:56:51 2003 # Expect and autoexpect were both written by Don Libes, NIST. # # Note that autoexpect does not guarantee a working script. It # necessarily has to guess about certain things. Two reasons a script # might fail are: # # 1) timing - A surprising number of programs (rn, ksh, zsh, telnet, # etc.) and devices discard or ignore keystrokes that arrive "too # quickly" after prompts. If you find your new script hanging up at # one spot, try adding a short sleep just before the previous send. # Setting "force_conservative" to 1 (see below) makes Expect do this # automatically - pausing briefly before sending each character. This # pacifies every program I know of. The -c flag makes the script do # this in the first place. The -C flag allows you to define a # character to toggle this mode off and on. set force_conservative 1 ;# set to 1 to force conservative mode even if ;# script wasn't run conservatively originally if {$force_conservative} { set send_slow {1 .1} proc send {ignore arg} { sleep .1 exp_send -s -- $arg } } # # 2) differing output - Some programs produce different output each time # they run. The "date" command is an obvious example. Another is # ftp, if it produces throughput statistics at the end of a file # transfer. If this causes a problem, delete these patterns or replace # them with wildcards. An alternative is to use the -p flag (for # "prompt") which makes Expect only look for the last line of output # (i.e., the prompt). The -P flag allows you to define a character to # toggle this mode off and on. # # Read the man page for more info. # # -Don set timeout -1 spawn telnet localhost 8888 match_max 100000 expect -exact "Trying 127.0.0.1...\r\r Connected to Crenel.speakeasy.net (127.0.0.1).\r\r Escape character is '^\]'.\r\r This MUD comes with ABSOLUTELY NO WARRANTY;\r for details, type \"help warranty\" after login.\r The server is public domain and you are welcome\r to redistribute it under certain conditions;\r Type \"help copying\" for details.\r \r This is a Phantasmal-based MUD. See\r \"http://phantasmal.sf.net\" for details.\r \r The owners of this MUD can customize this file.\r It's located in /usr/game/text/welcome.msg. But\r they haven't done so yet.\r \r Enter Account Name or Close Connection Now\r \r Account Login: " send -- "admin\r" expect -exact "admin\r Password: " send -- "admin\r" send_user "\rExpect: Logged in.\r"; expect "Exits:"; expect "# "; send -- "@goto #300\r" expect -exact "@goto #300\r You teleport to student lounge.\r # " send -- "s\r" expect -exact "s\r hallway\r The hallway smells vaguely of old floor polish and dust. Checkered tile\r reminds you of cheap cafeterias. A large hardwood door is permanently\r stuck open to the north, leading to the student lounge. To the west\r is the front of the building. Closed, long-locked doors line the south\r and east.\r *****\r \r Exits: n w \r # " send -- "w\r" expect -exact "w\r Steps of Building\r The front steps of Peabody Hall are old, well-maintained and wooden.\r Through a door, you can see the front hallway of Peabody to the east,\r and the M.U. campus stretches all around you. Several other academic\r halls can be seen to the north and south. The Tower is visible to\r the west.\r *****\r " expect -exact "\r Exits: e n s \r # " send -- "look turnip\r" expect -exact "look turnip\r You see a plump, juicy turnip. Well, I mean, plump and juicy for a turnip.\r # " send -- "%full_rebuild\r" expect -exact "%full_rebuild\r Recompiling auto object...\r Done.\r # " send -- "@zonelig" expect -exact " " send -- "st\r" expect -exact "st\r No command: @zonelist\r # " send -- "@zonemap\r" expect -exact "@zonemap\r Zones:\r 0: Unzoned\r 1: Miskatonic University\r 2: Innsmouth\r -----\r # " send -- "@set" expect -exact " " send -- "gme" expect -exact " " send -- "ap\r" expect -exact "ap\r Segments:\r 0 /usr/common/sys/mapd 0\r 1 /usr/common/sys/exitd 0\r 2 /usr/common/sys/mapd 0\r 3 /usr/common/sys/mapd 1\r 4 /usr/common/sys/mapd 1\r 5 /usr/common/sys/mobiled 0\r 6 /usr/common/sys/mapd 2\r --------\r # " send -- "say Hi!\r" expect -exact "say Hi!\r You say: Hi!\r # " send -- "emote sits like a brick.\r" expect -exact "emote sits like a brick.\r Admin sits like a brick.\r # " send -- "help\r" expect -exact "help\r As an administrator and/or builder, you'll need to know about the\r various commands you can use. Many of these commands are prefixed\r with a @ or % to distinguish them from normal commands and remind you\r of the harm they can do if used carelessly. Any of these helpfiles\r must be accessed with the help command.\r \r help builder Builder commands\r help admin Administrator commands\r help resource Resource and quota commands\r help guts Commands dealing directly with LPC\r \r help syntax Using any commands\r \r For the \"normal help\" screen, type \"help player_index\".\r # " send -- "help zones\r" expect -exact "help zones\r Zones are units of building and of administration. Zone borders will\r be in-game limits for some mobiles' movement. A zone consists of a\r number of segments. Here are some zone-related help topics:\r \r @segmap Shows information about segments, including their zone\r segment How to manage segments\r @set_seg_zone Sets the zone for a given segment\r @zonemap Show the current zones\r @new_zone Adds a new zone to the @zonemap\r \r To manipulate things within a zone such as rooms, see their\r individual help topics.\r # " send -- "@stat #300\r" expect -exact "@stat #300\r Number: 300\r Location: #0 (The Primordial Void)\r Descriptions (enUS)\r Brief: 'student lounge'\r Glance: 'student lounge'\r Look:\r 'This room has several old, large couches here and there. A table in\r the middle of the room seems to be built directly into the floor somehow.'\r Examine:\r (defaults to Look desc)\r Article: Definite (the)\r Nouns (enUS): lounge\r Adjectives (enUS): \r \r Its weight is 2000 kilograms.\r Its volume is 1000000 liters.\r Its length is 1000 centimeters.\r The object is an open container.\r The object may not be freely opened and closed.\r *** (enter to scroll forward, q to quit) ***\r " send -- "\r" expect -exact "\r It contains 0 of a max of 2000000 kilograms.\r It contains 0 of a max of 27000000 liters.\r Its maximum height/length is 1500 centimeters.\r \r Contains objects \[0\]: \r Contains 0 mobiles.\r \r Has immediate details \[3\]: #400 #401 #402 \r Registered with MAPD as a room or portable.\r # " send -- "giggle\r" expect -exact "giggle\r You giggle to yourself.\r # " send -- "look\r" expect -exact "look\r Steps of Building\r The front steps of Peabody Hall are old, well-maintained and wooden.\r Through a door, you can see the front hallway of Peabody to the east,\r and the M.U. campus stretches all around you. Several other academic\r halls can be seen to the north and south. The Tower is visible to\r the west.\r *****\r " expect -exact "\r Exits: e n s \r # " send -- "@goto #1\r" expect -exact "@goto #1\r You teleport to Meat locker.\r # " send -- "look\r" expect -exact "look\r Meat locker\r This room is very cold, and you can smell iron in the air. Hooks come\r down from the ceiling almost everywhere, and hanging carcasses and\r intervening walls block your view. You're not sure how far away the\r walls are.\r *****\r " expect -exact " \r Exits: w e n s nw se ne sw \r # " send -- "giggle dog\r" expect -exact "giggle dog\r You giggle to yourself.\r # " send -- "giggle turnip\r" expect -exact "giggle turnip\r You giggle to yourself.\r # " send -- "quit\r" expect eof