Order of entries in the log

Remember this is a 1.44Mb floppy disk router, space is limited.

Order of entries in the log

Postby Islander » Fri Apr 06, 2012 10:24 am

I vould like to have the logs with the most recent post on top when I open the log in the Control Panel. As it is now you always have to scroll down to se the most recent entries.

Islander
User avatar
Islander
Newbie
 
Posts: 8
Joined: Mon Jan 19, 2004 3:37 am

Re: Order of entries in the log

Postby dingetje » Sun Apr 08, 2012 11:25 am

The lastlog command simply uses 'cat' to list the /var/messages.old and /var/messages files.
Unfortunately FREESCO doesn't have the 'tac' command which is similar to 'cat' but as the name implies lists the output in reverse order.

But not all is lost, because FREESCO does have the 'sort' command out of the box. So here's how to get the desired results:

1. login as 'root' via a shell session
2. cd /wwa/cgi
3. edit usr.cgi
4. look for 'messages'
5. Old code:
Code: Select all
log*)   ttl; $E
        cat /var/log/messages.old 2>/dev/null
        $E
        cat /var/messages
        $E
        end;;

6. New code:
Code: Select all
log*)   ttl; $E
        cat /var/messages | sort -M -r
        $E
        cat /var/log/messages.old 2>/dev/null | sort -M -r
        $E
        end;;

7. Save changes
8. Use 'Recent Log' command in Control Panel, should be in reverse order now.
GreetZ
http://dingetje.homeip.net

"Software is like sex: it's better when it's free." - LINUS TORVALDS
User avatar
dingetje
FREESCO GURU !!
 
Posts: 1004
Joined: Wed Nov 14, 2001 12:13 pm
Location: The Netherlands

Re: Order of entries in the log

Postby Lightning » Sun Apr 08, 2012 11:20 pm

Unfortunately the built in sort command in the 04x series does not support the -M flag. However the -r flag should do the job on it's own. Also the usr.cgi file is quite a bit different. So you will need these changes in the 04x series.
Old code lines 173~175
Code: Select all
inflog*)ttl;cat /var/log/infolog.old 2>/dev/null|$Fl;cat /var/infolog|$Fl;end;;
login*) ttl;cat /var/secure.old 2>/dev/null|$Fl;cat /var/secure|$Fl;end;;
log*)   ttl;cat /var/log/messages.old 2>/dev/null|$Fl;cat /var/messages|$Fl;end;;

New code lines 173~175
edit /wwa/cgi/usr.cgi
Code: Select all
inflog*)ttl;sort -r /var/log/infolog|$Fl;sort -r /var/infolog.old 2>/dev/null|$Fl;end;;
login*) ttl;sort -r /var/secure|$Fl;sort -r /var/secure.old 2>/dev/null|$Fl;end;;
log*)   ttl;sort -r /var/log/messages|sort -r|$Fl;sort -r /var/messages.old 2>/dev/null|$Fl;end;;


To make the above changes survive a reboot you will need to do the following commands as well in the 04x series
Code: Select all
mkdir /boot/cpc/cgi
cp /wwa/cgi/usr.cgi /boot/cpc/cgi/usr.cgi
If you are afraid that you might make a mistake. The chances are high that you will never learn anything.
User avatar
Lightning
FREESCO GOD !!
 
Posts: 3049
Joined: Wed Nov 14, 2001 6:50 am
Location: Oregon, USA

Re: Order of entries in the log

Postby dingetje » Thu Apr 26, 2012 3:26 pm

As a matter of fact I do have a working tac executable for FREESCO.
It's part of the coreutils package for 03x.

If you want to experiment with it, the binary can be downloaded from here:
http://dingetje.homeip.net/downloads/tac.gz

Simply unpack in /pkg/bin and you should be able to run the 'tac' command which is similar to 'cat' but lists the text file in reverse, so last line first.
GreetZ
http://dingetje.homeip.net

"Software is like sex: it's better when it's free." - LINUS TORVALDS
User avatar
dingetje
FREESCO GURU !!
 
Posts: 1004
Joined: Wed Nov 14, 2001 12:13 pm
Location: The Netherlands


Return to FREESCO wish list

Who is online

Users browsing this forum: No registered users and 1 guest

cron