This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

reading last line of logfile

Help for those learning Tcl or writing their own scripts.
Post Reply
N
NewzLive
Voice
Posts: 4
Joined: Wed Jul 04, 2007 10:31 am

reading last line of logfile

Post by NewzLive »

Hi there - I'm occasianally getting error messages to do with reading web pages and the only way to resolve it is to kill/restart the bot.
I'm wondering if there's a way to read the last line of the eggdrop.log file every few minutes, and if it detects this:

couldn't open socket: host is unreachable

then kill the bot?

Thanks in advance.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

That's the worst way for solving this problem. Obviously, this is not a normal behavior for the bot. You should try to fix the script which is causing the problem.
N
NewzLive
Voice
Posts: 4
Joined: Wed Jul 04, 2007 10:31 am

Post by NewzLive »

it's not the script - its just the website sometimes causes it to do that.
but thanks for the useless reply anyway.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I think what Sir_Fz was referring to, was to write a script that is capable of recovering from an unreachable host by itself, rather than requiring your whole bot to be restarted...

As for your question, run a crontab with a simple bash-script, something like this:

Code: Select all

if test ` tail -n 1 somelog | grep "couldn't open socket: host is unreachable -c` -ne 0
 then kill -9 `cat pidfile`
 ./configfile
fi
(Modified from a script I used to track apache-logs, might need further modifications...)

Of course, this is only one way of doing it with bashscripts, you could probably write something equivalent in tcl, perl, C, etc
NML_375
Post Reply