Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ Question regarding the log file

Question regarding the log file

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Stoned00d   (14 posts)  Bio
Date Wed 16 Jan 2002 11:29 PM (UTC)
Message
Is there any way to open the log file and check for certain strings while it's logging?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 17 Jan 2002 02:15 AM (UTC)
Message
You might be able to open a disk file from within VBscript - I don't remember the syntax but I think Krenath knows it.

However why not just make a trigger to match on the text as it arrives?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Krenath   USA  (76 posts)  Bio
Date Reply #2 on Thu 17 Jan 2002 03:56 AM (UTC)

Amended on Thu 17 Jan 2002 04:21 AM (UTC) by Nick Gammon

Message
Microsoft's samples for using the FileSystem Object in VBscript/Javascript can be found at
http://msdn.microsoft.com/library/en-us/script56/html/sgworkingwithfiles.asp

To open and read a file from disk (in vbscript):


Const ForReading=1
'Const ForWriting=2 'Not needed here
Dim oFS,oFile,sText
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFile = OpenTextFile("c:\Program Files\MUSHclient\Logs\world.log",ForReading)
While not oFile.AtEndOfFile
   sText = oFile.ReadLine()
   'Here's where you'd check the text line for 
   'some specific text
Wend
oFile.Close
Set oFile=Nothing
Set oFS = Nothing


Does MUSHclient close the logfile between logwrites, Nick? If not, the above script might have trouble accessing the logfile.

Similarly, if MUSHclient opens, writes, and closes the log file, it may have trouble reopening it again if the above script is busy looking for something.

Like Nick says, you're best off just setting a trigger directly against the input from the world.

- Krenath from
bDv TrekMUSH
ATS TrekMUSH
TNG TrekMUSE
TOS TrekMUSE
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 17 Jan 2002 04:20 AM (UTC)
Message
Quote:

Does MUSHclient close the logfile between logwrites, Nick? If not, the above script might have trouble accessing the logfile.


No it doesn't. That would be too time-consuming. However some programs can open files that are in use, and some can't. I would try it and see.

However I agree that using a trigger seems the simpler option (especially as I suggested it in the first place!).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Stoned00d   (14 posts)  Bio
Date Reply #4 on Mon 21 Jan 2002 04:22 PM (UTC)
Message
well, I guess I should have asked the following question in the first place: how can I trigger off of more than 1 line of text? I tried to copy/paste and clicked on the little "..." box next to the condition field, but when I tried it, the trigger didn't work.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Mon 21 Jan 2002 08:27 PM (UTC)
Message
You can't directly, because the triggers are matched at the end of each line (a multiple-line paragraph is counted as one line).

If you wanted to do that you would have to use multiple triggers. eg. if you wanted to match on:


AAA
BBB
CCC


You could make one trigger that matched on "AAA" and set a flag (eg. a variable). Ditto with "BBB", and then when you get "CCC" you check to see if the flag is set. Of course the variable would need to be cleared if neither "AAA" or "BBB" arrived. You can do that by using trigger sequence numbers.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


21,649 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.