Forums » Bugs

Cant touch errors.log

Mar 22, 2005 tramshed link
Har, anytime i try to mess with errors.log while vendetta is running, it stops outputting to it, any helpful hints, etc. (im trying to remove specific lines from it so they dont get evaluated twice)
Mar 23, 2005 raybondo link
That's just the way filesystems work.
Andy says to use tail or whatever.
Make a new file that you can mess with.

Normally you can read errors.log but you can't edit it because once you save your changes, the filesystem unlinks the old file and creates a new one. So the file handle that vendetta has open now points to an unlinked file and its output goes to oblivion.
Mar 23, 2005 tramshed link
the problem with tailing it is that if i output the tail to another file, the file im outputting to is still open, so the same problem arises. Maybe its just time to move all of this out of bash, which I really dont wanna do, but Id really like to improive my scripts handling of errors.log a bit more before I move on to adding anything more complex to it.
Mar 23, 2005 roguelazer link
/me points to the ruby port.
Mar 23, 2005 terjekv link
ray, if you write to a file that has been deleted, it isn't exactly lost. /proc/<pid>/fd/ will have a copy of the file. meddeling there though, is usually a sign you're doing something wrong. :-)
Mar 23, 2005 raybondo link
Ok, good point, terjekv.
Mar 24, 2005 tramshed link
/me gets tempted to meddle. Orrrrr, mail me your current ruby port Rogue, since I already know what it does, itll help me quickly learn ruby.
Mar 24, 2005 Spider link
just use "ed" to meddle.
ed is the editor, and doesn't do backup copies. it edits directly inside the inode.

However, you may well fuck up the files if you do so.
Mar 24, 2005 terjekv link
Spider, if you use 'ed', you're already so fucked up that it can't get much worse.

that being said, I've used ed. quite a lot actually. it is the standard unix editor after all. :-)
Mar 24, 2005 kihjin link
If I understood more of what was trying to be accomplished, I could perhaps be of more assistance.

tramshed, if possible, could you explain to me what you are trying to do? I understand that you are trying to remove lines from errors.log... but, not why.
Mar 24, 2005 roguelazer link
He's trying to parse errors.log and then remove the lines that he's already parsed so that his parser doesn't go over them again. This is because of his choice of programming language, which severely limits the functional structures he can use. Thus my ruby port, which will bypass this with my homemade version of tail that includes this functionality out-of-the-box. And also takes a long time to write.
Mar 24, 2005 Solra Bizna link
Heh. None of these problems hit me with my C/Lua bots.
I won't get into some of the problems that did hit me, though.
-:sigma.SB
Mar 25, 2005 kihjin link
Alright, I came up with the following script. It's really simple doesn't do anything in terms of performing actions, but it does allow you to parse the errors.log 'file' in real time.


#!/bin/bash
#############

parse() { echo "LINE: '" $1 "'" }

rm -f errors.log
mkfifo errors.log

cat errors.log | while read LINE; do
parse "$LINE"
done

#############
### end of script
#############


Be sure to chmod +x script.sh or whatever you name it, so you can execute it. Regardless, VO needs to be *off* when you run this script. When you do this, the script will block indefinitely until it receives input from VO. Once you start VO, the output will appear in the terminal you ran the script in.

Here's what I got:

/*--------------------------*/

[frozen@frozen ~/.vendetta]$ ./s.sh
LINE: ' [Fri Mar 25 02:38:35 2005] Found driver: "ALSA driver". Type 1, Version 8.1. Load @0x082db800 '
LINE: ' [Fri Mar 25 02:38:35 2005] Instantiate address: 0xb7518980 '
LINE: ' [Fri Mar 25 02:38:35 2005] Found driver: "Open Sound System driver". Type 1, Version 8.1. Load @0x082dc328 '
LINE: ' [Fri Mar 25 02:38:35 2005] Instantiate address: 0xb742c2b0 '
LINE: ' [Fri Mar 25 02:38:35 2005] Found driver: "OpenGL Reference GKGL driver". Type 5, Version 29.0. Load @0x082dc5a0 '
LINE: ' [Fri Mar 25 02:38:35 2005] Instantiate address: 0xb7401e20 '
LINE: ' /dev/js0: No such file or directory '
LINE: ' /dev/input/js0: No such file or directory '
LINE: ' /dev/js1: No such file or directory '
LINE: ' /dev/input/js1: No such file or directory '
LINE: ' /dev/js2: No such file or directory '
LINE: ' /dev/input/js2: No such file or directory '
LINE: ' /dev/js3: No such file or directory '
LINE: ' /dev/input/js3: No such file or directory '
LINE: ' Found 0 joystick(s) '
LINE: ' ALSA initialized: 44100Hz, 16bit stereo, 185ms latency (8 periods x 1024 samples) '
LINE: ' [Fri Mar 25 02:38:54 2005] Welcome to Vendetta Online. '
LINE: ' [Fri Mar 25 02:38:57 2005] Channel 100 is active. '
LINE: ' [Fri Mar 25 02:38:57 2005] ffffffNone of your buddies are currently online. '
LINE: ' [Fri Mar 25 02:38:59 2005] ffffffPeople in the bar: kihjin '
LINE: ' [Fri Mar 25 02:38:59 2005] You are now in Aputik Outpost (Axia Mining). '
LINE: ' [Fri Mar 25 02:39:17 2005] 28b4f0[100]<kihjin> testing bash script '
LINE: ' [Fri Mar 25 02:39:22 2005] 28b4f0[100]<yodaofborg> Submit! '
LINE: ' [Fri Mar 25 02:39:26 2005] 28b4f0[100]<Martin.mac.au> lol '
LINE: ' [Fri Mar 25 02:39:28 2005] 28b4f0[100]<kihjin> wonderful '
LINE: ' [Fri Mar 25 02:39:37 2005] 28b4f0[100]MysticRogue rolls eyes at yoda '
LINE: ' [Fri Mar 25 02:40:34 2005] 28b4f0[100]kihjin is signing off '
LINE: ' [Fri Mar 25 02:40:35 2005] 28b4f0[100]<Mecha Touriuas> tumble and martin kos '

/*--------------------------*/

(I took out some of the middle chatter to make it smaller)

I don't know if anyone has tried that before, but... I just did and it works alright. Feel free to use the script or its ideas in your own, provided I get some credit towards it, of course :)
Mar 25, 2005 roguelazer link
Well, you could just do the same thing with tail...
Mar 25, 2005 kihjin link
roguelazer, no, you could not. Not in the same way.

In the script I wrote, the script itself acts as the relayer of the output produced by VO. It's a middle man. If you wanted to, you could actually store all those lines in another file, several files, instead of printing them to the screen (I just did that as an example).

Now, tail does not work properly with named pipes. Like cat, it will block until it receives input. tail will not do anything until it gets to the EOF of the input, and then it traces back 'n' number of lines, and prints only those lines to the screen. In this way, tail merely acts as an observer of past data.

With a regular file, tail works... somewhat well. I'm guessing you'd want to run 'tail -n 1' just so to get the last line of the file. And then, in order to constantly "scan" the file, you'd have to have tail in some sort of loop. A problem occurs when you loop over and there's no new messages... that same message you already parsed is still at the end. You can't edit it out, because if you do that, you modify the file's append position, and VO loses "where" to store all that data.

Once again, I'm at a small disadvantage because I can't see the big picture. Perhaps what you need can be accomplished with tail. Based on what I've encountered with the program, I don't think tail is a wise way to perform this task.
Mar 25, 2005 roguelazer link
kihjn: which is why tail has the -F arguement... But it's irrelevant. The bash version is dead forevermore, let there be much rejoycing. This entire thread is irrelevant.
Mar 25, 2005 tramshed link
Since when was it dead?