Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Minecraft chat logger

Name: Anonymous 2011-01-09 5:53

Hi /prog/,

I have a problem with a Bash script.
I tried to write a little script to create a chat only log for minecraft.
The script is here:
http://pastebin.com/6TVkgvsc

However, when I test it, this is written to chat.log:

21:02:17 <tim> blah
21:03:49 <tim> hi
21:06:13 <tim> test
21:06:13 <tim> test
<tim> test
<tim> dayum
21:07:52 <tim> dayum
21:07:52 <tim> dayum
21:10:08 <tim> talk
21:10:08 <tim> talk
21:10:08 <tim> talk
<tim> talk

I said all those things only once.

I have no fucking idea why this happens.
For each message, the output of the script is just once "not the same; updating", it's not like Minecraft was just nog finished with logging.

Could someone help me out here?

Name: Anonymous 2011-01-09 6:02

just don't print shit with the same time and message

Name: OP !8K1gD5K2Z6 2011-01-09 6:07

>>2
What do you mean?

Name: Anonymous 2011-01-09 6:11

>>3
the problem is that it is printing the same thing too many times, just make it stop doing that by checking if it is already written

Name: Anonymous 2011-01-09 6:13

if not line in lines
  print line
  append(lines,line)

Name: OP !alreadyforgotmytrip 2011-01-09 6:30

>>4
yeah, but why would it do that?
I only write it once.

Name: Anonymous 2011-01-09 6:39

>>6
You really are a faggot and you should get the fuck out of {spoiler /prog/} because if it sucks it's because of people like you, but I'm going to help you:

last=""
while get the next line, put it in $line; do
  if [[ $line == $last ]]; then
    # it's the same as the last line, don't print
  else
    last="$line"
    print $line
  fi
done
# repeat

Name: Anonymous 2011-01-09 6:43

>>7
/prog/

Name: Anonymous 2011-01-09 6:47

More like autismcraft

Name: Anonymous 2011-01-09 19:30

Here's an idea:


tail -f $logfile |
while read line
do
    # line test & logging code
done


Better yet, use awk and grep to test the line and do the whole thing on a single line, then write an alias for it and stick it in your .bashrc file. Filtering logs in bash almost never needs more than tail -f ... | awk ... | grep ... >> ..., with maybe sed or tee in there too if you swing that way.

Name: Anonymous 2011-01-31 19:46

<-- check em dubz

Name: Anonymous 2011-02-03 2:54

Name: Anonymous 2011-02-04 18:06

Name: Anonymous 2011-08-04 17:25

hi

Don't change these.
Name: Email:
Entire Thread Thread List