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

Re: [Sheflug] HTML Logs



On Fri, May 16, 2003 at 11:58:12AM +0100, Richard Ibbotson wrote:
> Can any of our Perl or scripting people out there explain what's wrong
> with this script ?
> 
> 
> #!/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>`

Three things. First, you are using a backquote (`) in the echo statements.
A backquoted string tells the shell to execute the string, then substitute
its output, eg

    FOO_FILES=`ls | grep foo`

So you want to use ordinary quotes instead, ie (').

Second, you haven't got a matching quote at the end of the second echo
line.

Third, I don't know whether its just your mailer doing wrappinng,
but the end of the sed line has been joined to the echo line.
Also, It's a long time since I've used sed, and I can't remember whether
it allows a s/// to split over several lines.

I haven't looked closely at the actual sed line to see whether it's
correct.

Dave.


-- 
A walk of a thousand miles begins with a single step...
then continues for another 1,999,999 or so.
___________________________________________________________________

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

  GNU the choice of a complete generation.