Newbie but willing

moop

New member
I've been studying the tutorial and some other scripts. I can get some scripts to work if I call them from the dropdown menu, but when I want one to work "On Login," it doesn't work. I want to set up a script (and schedule KoL Mafia to run each day with the script) for a friend who will be going on vacation.

I've been to the IRC channel because I didn't think this warranted a post on these forums, but... the IRC channel has three other people, all afk. So that brings me to plugging the IRC channel, which was posted on the KoL forums:

irc://irc.freenode.net/#kolmafia :D
 

Nightmist

Member
>> Sorted this out in the IRC channel I think... Well if you have any more problems feel free to post again or maybe find me on that IRC channel.
 
The trick is to use a MS-Dos Batch file to start a special mode in kolmafia called CLI Mode.
Download the Jar version instead of the exe, then create a batch file similar to the following.
Code:
java -jar KoLmafia-7.6.jar --CLI script=scripts\scriptname.ash
or
Code:
java -jar KoLmafia-7.6.jar --CLI script=scripts\scriptname.txt
just like when you are saving an ash script, you must change the extension when you save the file. Save it with the .bat extension. Save the batch file in the same directory as kolmafia. Note change 7.6 to the version of kolmafia you ar using. It goes without saying that "scriptname" is the name of your script.

If you are using an ash script, it is easier to set up a seperate non ash script to handle logon. Save that file with a .txt extension. and call it in the batch file.
Code:
login username
call scripts\scriptname.ash
Logout

using a .txt file to handle logon has many many advantages. the main script could be used to handle multiple characters is one. The second is when modifying the main script it can be started from the normal user interface.

Now instead of scheduling kolmafia to run each day, schedule the batch file to run. The batch file will start kolmafia. kolmafia will not have the user interface when ran this way. If the script halts and cannot continue, then type "priphea" and press enter, and the normal user interface you are used to will appear.

Of course, you must have the password for the character saved in order for kolmafia to be able to log on using this method.

For testing, you can double click the batch file in windows, and it will run.

Double clicking the jar version of kolmafia in windows starts it the in the same way as the exe, so you wont need to keep the exe around unless you just want to.

Hmm, guess Nightmist beat me to it.
 

moop

New member
Thank you both very much! Alrighty, I still have a few questions.

  • The command-line function as you presented it, runs the CLI in terminal, yet the documentation says my password must be in a file and to my knowledge, it doesn't elaborate. Do you know where this information is? Shouldn't it be in the documentation? Is it somewhere and I am just blind? What is the syntax for passing the correct password to the CLI (it says it stores the password automatically, but I don't know where it would find and pass along that information - I'm guessing I might need to make a simple text password file, otherwise I am not telling it how to properly pass that information along, right?).

    kolmafiaterminal9zn.png

  • So... the "On Login" function in the GUI... isn't supposed to work? Doesn't work? Doesn't work unless [some condition]? This therefore necessitates command-line use when doing login-to-logout scripts? Sorry, I am quite willing to take the command-line route, but I don't see why (short of a bug) that the built-in On Login function wouldn't (apparently, in my case) do anything. I have used both simple scripts and an .ash, both of which work perfectly fine only if I call them after successfully logging into KoL mafia.

I have tested this in windows, but not in SuSE linux yet, although that wouldn't matter, since my friend does not have a linux installation, and our goal is to run these scripts on her machine.
 

Nightmist

Member
[quote author=moop link=topic=182.msg916#msg916 date=1148917258]
yet the documentation says my password must be in a file and to my knowledge, it doesn't elaborate. Do you know where this information is? Shouldn't it be in the documentation? Is it somewhere and I am just blind? What is the syntax for passing the correct password to the CLI
[/quote]

Just login normally through the GUI and make sure you have "Save Passwords" checked. This saves the password is a .kcs file and then in the script a "login username" automatically pulls the password from there.
 

moop

New member
I already left that box checked. I have five files in my data directory though:

~.kcs
~moop.ccs
~moop.kcs
DesktopIndicator.dll
KoLmafia.log

Neither of the two .kcs files contain my password. Is it located somewhere else? Does the CLI have some undocumented way of passing the password from the command line?
 

Nightmist

Member
[quote author=moop link=topic=182.msg923#msg923 date=1148951976]
I already left that box checked. I have five files in my data directory though:

~.kcs
~moop.ccs
~moop.kcs
DesktopIndicator.dll
KoLmafia.log

Neither of the two .kcs files contain my password. Is it located somewhere else? Does the CLI have some undocumented way of passing the password from the command line?
[/quote]

Mafia isnt daft enough to store the password in plain text if thats what your looking for, its in the "~.kcs" file and under the line "saveState.Username=NumericalLineMakingUpYourPassword". (Or so I am led to believe but ive never manually messed with the stored passwords so I may be wrong)

Incase your wondering the .ccs files are the "Custom Combat Settings" files.
 

moop

New member
Any idea why is it not getting passed to the CLI in the screenshot in my earlier post?


Ah! Gold!

(and sorry for the double-post, but I have an update)
I spoke with bigfreak in the IRC channel, and we did a bit of work in VNC and discovered that with the "Breakfast" option in the GUI unchecked, the On Login script would not run.

The CLI version also needed to have the login and password passed manually in plaintext in the script file at least once to be saved. I will continue to test login-to-logout scripts.

Thank you everybody for helping narrow down this problem!

( please do not double post ;D )
 
[quote author=moop link=topic=182.msg934#msg934 date=1149000624]
Ah!  Gold!

(and sorry for the double-post, but I have an update)
I spoke with bigfreak in the IRC channel, and we did a bit of work in VNC and discovered that with the "Breakfast" option in the GUI unchecked, the On Login script would not run. 

The CLI version also needed to have the login and password passed manually in plaintext in the script file at least once to be saved.  I will continue to test login-to-logout scripts. 

Thank you everybody for helping narrow down this problem!
[/quote]

One quick question, did you save the jar or "cli" version to a different folder than the original version you had? I have never had to enter my password into cli mode, but I also put all versions of kolmafia in the same folder so they use the same settings files.
 

moop

New member
All my old versions are in the same folder, yes.

I'm still getting inconsistent results, especially with the "Breakfast" checkbox. I'll make a list of what I experience, and maybe someone interested can test if they can replicate it.
 
Top