Accessing mud output

Posted by Khorlane on Wed 12 Sep 2001 12:00 PM — 4 posts, 15,966 views.

#0
I need to access the results of a mud command. The result of this command could be 1 to n lines, each of which is identical the previous except for a 'count' value. Here's an example:

Comand:
where smallrat

Result:
M 1. a small rat - [ 184] North Way
M 2. a small rat - [ 186] Jesse Square
M 3. a small rat - [ 103] West Way
M 4. a small rat - [ 126] Adam Street
M 5. a small rat - [ 186] Jesse Square
M 6. a small rat - [ 103] West Way
M 7. a small rat - [ 103] West Way

I need to parse the last line of the result. Is there any way to accomplish this without writing the log to a text file and then reading the captured log text file?

Australia Forum Administrator #1
I think you can do that OK with triggers. The main problem is to know which is the last line, as I gather you won't know in advance if it is 7 lines or 20.

However you would have exactly the same problem with writing to a file and reading it back in - you need to know when to do that.

I would make a trigger that matches on the result lines, eg. something like:


^M \d+\. (.*?)$


This trigger could call a script, or simply send %1 to a variable (for later use).

Then have a second trigger that matches whatever it is that tells you that the list has ended.

Then in the second trigger you retrieve the results of the variable and parse it.

#2
Yes indeed, the list is of unknown length and nothing stands out as an 'end of list' indication. So, the second trigger is a problem ... maybe it could be a 'oneshot' timer set to fire after 5 seconds. The 5 seconds is more than enough time for the "where smallrat" command to finish.

Possible Trigger Solution:

Set up trigger:
^M \d+\. (.*?)$ to save %1 in a variable

vbscript: pseudo code: Script1

World.send "where smallrat"
-- 1st trigger saves line in variable for later use.
-- oneshot timmer to wait 5 seconds for "where smallrat" to finish, then executes Script2 to examine variable.
World.addtimer "my_timer", 0, 0, 5, "", 5, "Script2"


Also, would this work?

Possible Log Capture Solution:

vbscript:

World.openlog "mylog.txt", false
World.send "where smallrat"
World.closelog
-- code here to open, read, parse, close mylog.txt --



Thanks for your help.

Steve
Australia Forum Administrator #3
The timer might work but sounds a bit wonky - it might fail if the server was slow.

I would do something like this:

  • Activate a trigger to match on "M <number> ..."
  • When the first trigger fires (for the first time - you could use a counter) activate a second trigger to match on everything (eg. "*")
  • In the second trigger, when a line arrives that doesn't start with "M <number>" you know you have reached the end of the list.


Or perhaps more simply, just have one trigger that matches on everything (ie. "*"). In it you simply look for "M <number>". You could count them. Once the number of them is one or more, and a line arrives that doesn't start with "M" you know that the previous line was the last one (which you saved in a variable).


Quote:

World.openlog "mylog.txt", false
World.send "where smallrat"
World.closelog


This won't work because it would send "where smallrat" and immediately close the log. You need to pause for an unknown time to wait for the output to arrive. I think my trigger solution would work better.