After a brief discussion in /clan, I decided to whip up a quick hack to automate a KoLmafia command with expect. I installed expect on Debian. It turns out the Debian package is not very well tested; the basic "package require Expect" Tcl command didn't even work! I filed a bug. I don't know how that will turn out. Here's the script I wrote. It's called "outfit". ============================================================================= #!/usr/local/bin/tclsh8.6 # package require Expect load [file join /usr lib x86_64-linux-gnu libexpect.so.5.45] package require Expect if {[llength $argv] < 1 || [llength $argv] > 2} { puts stderr "usage: outfit kolname [outfitname]" exit 1 } set user [lindex $argv 0] set outfit pvp if {[llength $argv] == 2} {set outfit [lindex $argv 1]} set first 1 set timeout 60 spawn java -jar /var/tmp/KoLmafia.jar --CLI expect { username: {send "$user\r"; exp_continue} " > " { if {$first} {send "/outfit $outfit\r"} else {send "quit\r"} set first 0 exp_continue } timeout exit eof exit } ============================================================================= Here's an example of running it from a shell prompt. There is absolutely no interaction after the initial shell command. ============================================================================= titan:~$ ./outfit lightgreycat rollover spawn java -jar /var/tmp/KoLmafia.jar --CLI KoLmafia v17.1 r16339 Released on August 6, 2015 Currently Running on Linux Local Directory is /home/greg/.kolmafia Using Java 1.8.0_45 username: lightgreycat Installing default certificate validation... Validating login server (www.kingdomofloathing.com)... 522 players online. Sending login request... Initializing session for lightgreycat... Refreshing session data... Synchronizing moon data... Loading character status... Retrieving character data... Updating inventory... Examining Meat in closet... Updating closet... Retrieving quest data... Retrieving familiar data... Familiar data retrieved. Retrieving campground data... Examining Meat and pulls in storage... Updating storage... You are currently a member of Cat Fight! Visiting Hot Dog Stand in clan VIP lounge Visiting Speakeasy in clan VIP lounge Session data refreshed. 3 days until Oyster Egg Day, 2 days until Muscle. > /outfit rollover Equipping "rollover (#424)".
> quit Preparing for logout... Sending logout request... Logout request submitted. Logout completed. ============================================================================= This only works if KoLmafia has already stored your password internally. Otherwise, you'll have to add password handling to the expect script (not shown).