|
Help with a script - logging the output of a command.
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Virthe
(4 posts) bio
|
| Date |
Thu 24 May 2012 09:42 AM (UTC) [ quote
] |
| Message |
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? | top |
|
| Posted by |
Fiendish
USA (848 posts) bio
Global Moderator |
| Date |
Reply #1 on Thu 24 May 2012 12:50 PM (UTC) [ quote
] |
| Message |
Quote: Would I need to set up triggers to detect when the output of the command has finished?
Yes. |
http://aardwolfclientpackage.googlecode.com/ | top |
|
| Posted by |
Virthe
(4 posts) bio
|
| Date |
Reply #2 on Thu 24 May 2012 01:03 PM (UTC) [ quote
] |
| Message |
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? | top |
|
| Posted by |
Virthe
(4 posts) bio
|
| Date |
Reply #3 on Thu 24 May 2012 02:55 PM (UTC) [ quote
] Amended on Thu 24 May 2012 06:09 PM (UTC) by Virthe
|
| Message |
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? | top |
|
| Posted by |
Nick Gammon
Australia (18,770 posts) bio
Forum Administrator |
| Date |
Reply #4 on Fri 25 May 2012 01:05 AM (UTC) [ quote
] |
| Message |
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.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
Virthe
(4 posts) bio
|
| Date |
Reply #5 on Fri 25 May 2012 11:49 AM (UTC) [ quote
] |
| Message |
| Great! That fixed it. Thanks for your help. | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
918 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )