You are not logged in.
Hi all,
Playing with finch (a console im client), and haven't found any notification plugins for it that work the way I want.
What I have been doing is using tail to watch the logs. As the logs are in html, I use sed to strip the html tags:
tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* | sed -e 's#<[^>]*>##g'
I would like to use notify-send or dzen2 to create popup windows when the log file changes, but I'm not sure how (I am not an experienced programmer).
This, for example, does not work:
tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* | sed -e 's#<[^>]*>##g' | while read line ; do notify-send "${line}" ; done
Removing sed from the stream above allows notify-send to pop up notifications. How can I have the same happen with sed in there?
Last edited by hellomynameisphil (2011-10-22 17:49:34)
Offline
I am not an expert, but what if you use 'tee' and pipe the output of tail through both sed and while...done in parallel ?
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Online
Try this:
while read line
do
notify-send "$(sed -e 's#<[^>]*>##g' <<< $line)"
done < <(tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* )
Last edited by rockin turtle (2011-04-12 02:25:10)
Offline
Try this:
while read line do notify-send "$(sed -e 's#<[^>]*>##g' <<< $line)" done < <(tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* )
That did it. Thanks!
Offline
tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* | sed -e 's#<[^>]*>##g' | while read line ; do notify-send "${line}" ; done
Removing sed from the stream above allows notify-send to pop up notifications. How can I have the same happen with sed in there?
The problem here is that sed is buffering its output to improve efficiency in pipes. Try with:
tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* | sed -e 's#<[^>]*>##g' -u | while read line ; do notify-send "${line}" ; done
And should work as well
Regards
My blog: blog.marcdeop.com
Jabber ID: damnshock@jabber.org
Offline
Yes, damnshock, that works as well. Thank you.
Offline