Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: How to search old chat logs and convert chat logs to a more readable format?

  1. #11
    Join Date
    May 2011
    Beans
    278

    Re: How to search old chat logs and convert chat logs to a more readable format?

    Um... Sorry, I'm not even sure what bash and python are, except that python is a 'scripting language' which somehow differs from a programming language. I don't know what I'd enter the .sh and .py text in. I have something like 730 .log files to convert, too. Name formats are usually like 20110616.log with year, month, and day.

    P.S. So bash is a shell, and I suppose the bash commands can be entered in the terminal? but python is different. and Ubuntu for Non-Geeks mentions it but doesn't explain it.
    Last edited by MarjaE; March 16th, 2013 at 05:46 AM.

  2. #12
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,464
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to search old chat logs and convert chat logs to a more readable format?

    scripting languages are a subset of programming languages
    Either way you create empty text files, paste the contents, type in the proper path in .sh file and run bash whatever_name_you_picked.sh in terminal. Bash part will call python part automatically (so you don't touch python at all) as long as the names of .py file and .py called in the bash script match.

    If you want to have the logs conveniently glued into a single file for each friend account so the number is much lower (i would) tell me what is the exact structure, eg ~/.empathy_logs/protocol/user/20111121.log (i have no idea and i don't plan on using empathy to find out)



    edit: assuming the files are located in dirs where last two parts are /your_acct/buddy_name (the internet and the poster above claim that) the script below should create a file named "buddy_name (your_acct).txt" in the configured destination dir for each dir that contains .log files.

    empathy_logs2.sh
    Code:
    #!/bin/bash
    
    shopt -s nullglob
    
    # root dir of empathy logs
    logpath=.
    # destination dir for converted and merged files
    dest="$HOME/converted_logs"
    
    mkdir -p "$dest"
    
    while read -rd $'\0' d
    do
      files=( "$d"/*.log )
      (( "${#files[@]}"==0 )) && continue
      name=${d##*/}
      acct=${d%/*}; acct=${acct##*/}
      conv="$dest/${name} (${acct}).txt"
      rm "$conv" 2>/dev/null
      echo "converting log files from '$d' => '$conv'"
      for f in "${files[@]}"
      do
        python empathy_logs.py "$f" >> "$conv"
      done
    done < <( find "$logpath" -mindepth 1 -type d -print0 )
    same story: create empty file next to the .py file, name it whatever_you_want.sh
    and then run
    Code:
    bash whatever_you_want.sh
    you should get a dir full of txt files
    Last edited by Vaphell; March 16th, 2013 at 07:53 AM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #13
    Join Date
    May 2011
    Beans
    278

    Re: How to search old chat logs and convert chat logs to a more readable format?

    Okay, I put one of the backup directories into the logpath= section of the bash script, but I'm getting an error saying there's "no such file or directory." I checked all my spelling capitalization, and backslashes, but maybe I'm missing something more basic.

  4. #14
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,464
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to search old chat logs and convert chat logs to a more readable format?

    are there empathy logs there?
    logpath is where the source files are supposed to be located, dest where converted ones should land

    when it says no file or directory, does it give a name?
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  5. #15
    Join Date
    May 2011
    Beans
    278

    Re: How to search old chat logs and convert chat logs to a more readable format?

    Sorry for not getting back to you on this, didn't want to deal with fancy computer stuff with my rsi, but yes, there were/are empathy logs there.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •