Help with a script - logging the output of a command.

Posted by Virthe on Thu 24 May 2012 09:42 AM — 6 posts, 20,003 views.

#0
I need to log the output of a command to a file on my hard disk?

So far I have this:


OpenLog("D:\Users\User\Documents\AL\test")
SetLogOutput (true)
world.Send("cat %1")
FlushLog()


It doesn't work at all.

I need to log all the output of the 'cat' command.

How do I correctly use log to store the MUD output?

Would I need to set up triggers to detect when the output of the command has finished?
USA Global Moderator #1
Quote:
Would I need to set up triggers to detect when the output of the command has finished?

Yes.
#2
Okay, I think I can sort out the trigger (enabling and disabling it with SetTriggerOption).

I can't figure out how to get the log file working though. Am I on the right lines with that? Will it work if I move FlushLog() to the end of file trigger?
#3
Okay. I now have:


And an alias with the following script:
OpenLog("D:\Users\User\Documents\AL\log.txt",false)
SetLogOutput (true)

SetTriggerOption("eof","enabled","y")

world.Send("cat %1")


A trigger labelled "eof" with the following script:
FlushLog()
CloseLog()
SetTriggerOption("eof","enabled","n")


The trigger runs as planned and is enabled/disabled correctly.

However, the log file still doesn't work. No file is created. I have tried using the default log name with no success.

Is there anything else I need to do to enable/disable logging from the script?
Amended on Thu 24 May 2012 06:09 PM by Virthe
Australia Forum Administrator #4
You are short some backslashes. Inside a Lua string you need to double them, eg.


OpenLog("D:\\Users\\User\\Documents\\AL\\log.txt",false)


And if this is in "send to script" you have to double them again.
#5
Great! That fixed it. Thanks for your help.