[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Sheflug] HTML Logs



#!/bin/sh

echo `<h1>Log files in /var/log</h1><p>`
echo `<table border=1> <tr><th>Name<th>date<th>size<tr>
ls -ld /var/log/* |  \
sed -e "s/^[-rwxds]*[ 0-9]* \([a-z0-9A-Z]* *\)\{2\} \([0-9]*\)
\([A-Za-z]\{3\} *[0-9]\{1,2\} *[0-9:]*\)\/\4\5>\5<\/a><td>\3<td
align=RIGHT>
\2<tr>/"echo `</table>`

it bombs out with the following error message..

./logfile: line 8: unexpected EOF while looking for matching ``'
./logfile: line 9: syntax error: unexpected end of file

What I'm trying to do it turn my logs in /var/log into HTML pages so
that I can view them in a web browser.

Thanks

Where to begin....
Assuming perl and assuming your perl compiler requires ;s to end each
command:
line 1 has no ; at the end
Line 2 has no closing ' so all the remaining lines may be assumed to be part
of the same echo command
Line 2 also needs a ; if the above is true
Line 4 HTML tables should have <td> tags surrounding the cell contents.  I
couldn't quite work out what the output of your sed would be (it seems to
just be reordering the data on each log file line and inserting html tags)
but a) there is no closing </td> tag and b) the opening tag seems to be
after the data
You don't seem to have a closing </tr> tag

I've done this before and found it easier to write the HTML page as one file
and use comments as place holders for the start of the data (i.e. the line
to be repeated) and for each element I want to substitute in the table.  The
script then parses the html file and substitutes the comments for data from
the logs.  The advantages are that you can easily change the layout of the
page without messing with the script or change the script without changing
the layout.  This helps in debugging and also allows you to add hints and
tips to your web page for less knowledgeable readers without them being lost
in the midst of a script somewhere.  Admittedly its a little more than 6
lines.

If you want an example I'll see if I can get someone to email me one from
Sheffield Hallam where I left them running a couple of years ago...
HTH

ChrisJ

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.481 / Virus Database: 277 - Release Date: 13/05/2003


___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.