-
Convert text to HTML
Hi All,
Firstly this is what I am setting out to do.
I have a background script I wrote (I'm not very good with scripts at
all). The script runs tcpdump -n -e -ttt -r /var/log/pflog >pflog.txt
then sleeps for 30 seconds, then repeats the same command.
What I want to do, is somehow convert the data in pflog.txt into a HTML
page that refreshes every 60 seconds or so, so I can watch it in a web
browser. I'd probably want to tail -n 50 the data in the text file
before converting it because there will be a lot of output
I have apache on a diff box on my LAN, I can use wget to get pflog.txt
from the original machine, over to the machine running apache.. My issue
is with converting the text data.
Any clues or suggestions/urls?
I'm not afraid to RTFM, but which manuals to I need to read?
Thanks!!
Alex
-
Re: Convert text to HTML
alex <me@me.me> wrote:
[color=blue]
> Firstly this is what I am setting out to do.
> I have a background script I wrote (I'm not very good with scripts at
> all). The script runs tcpdump -n -e -ttt -r /var/log/pflog >pflog.txt
> then sleeps for 30 seconds, then repeats the same command.
> What I want to do, is somehow convert the data in pflog.txt into a HTML
> page that refreshes every 60 seconds or so, so I can watch it in a web
> browser. I'd probably want to tail -n 50 the data in the text file before
> converting it because there will be a lot of output
> I have apache on a diff box on my LAN, I can use wget to get pflog.txt
> from the original machine, over to the machine running apache.. My issue
> is with converting the text data.
> Any clues or suggestions/urls?
> I'm not afraid to RTFM, but which manuals to I need to read?[/color]
Here is an example which should explain everything. The example assumes that
/var/log/pflog is readable for the webserver user.
#!/bin/sh
echo "Content-type: text/html"
echo
echo "<html>"
echo "<head>"
echo "<title>pf log</title>"
echo "</head>"
echo '<META http-equiv="refresh" content="60">'
echo "<body>"
tcpdump -n -e -tttt -r /var/log/pflog | tail -n 50 | while read line; do
echo "$line<BR>"; done
echo "</body></html>"
HTH, Helmut
--
No Swen today, my love has gone away
My mailbox stands for lorn, a symbol of the dawn
-
Re: Convert text to HTML
Helmut Schneider wrote:[color=blue]
> #!/bin/sh
>
> echo "Content-type: text/html"
> echo
> echo "<html>"
> echo "<head>"
> echo "<title>pf log</title>"
> echo "</head>"
> echo '<META http-equiv="refresh" content="60">'
> echo "<body>"
> tcpdump -n -e -tttt -r /var/log/pflog | tail -n 50 | while read line; do
> echo "$line<BR>"; done
> echo "</body></html>"
>
> HTH, Helmut[/color]
This should help enormously :-) Thank you!!!
I did make an attempt of my own, but it didn't go quite to plan, I
couldn't figure out a way to get the <BR> on the end of each line in the
text file.
Cheers,
Alex
-
Re: Convert text to HTML
alex <me@me.me> wrote:[color=blue]
> Helmut Schneider wrote:[color=green]
>> #!/bin/sh
>>
>> echo "Content-type: text/html"
>> echo
>> echo "<html>"
>> echo "<head>"
>> echo "<title>pf log</title>"
>> echo "</head>"
>> echo '<META http-equiv="refresh" content="60">'
>> echo "<body>"
>> tcpdump -n -e -tttt -r /var/log/pflog | tail -n 50 | while read line; do
>> echo "$line<BR>"; done
>> echo "</body></html>"
>>
>> HTH, Helmut[/color]
>
> This should help enormously :-) Thank you!!!
>
> I did make an attempt of my own, but it didn't go quite to plan, I
> couldn't figure out a way to get the <BR> on the end of each line in the
> text file.
>
> Cheers,
> Alex[/color]
Not necessary.
Use instead,
<body>
<pre>
....
</pre>
</body>
-
Re: Convert text to HTML
YANSWBVCG wrote:[color=blue]
> Not necessary.
>
> Use instead,
>
> <body>
> <pre>
> ...
> </pre>
> </body>[/color]
Sweet, I'll take a look at this :-)
Thanks!