I have a little script that will format a log file with all failed logins for users on the system. I have written the script to output the data in a text file in this format (two columns with the number of failed login attempts in the first, and the user in the second):
1,325 Unknown 505 root 17 adm 16 ftp etc...
I need this file formatted in HTML output on the console in this way (each line in the file be printed on a html line break):
<html> <body><h1>Failed Login Attempts</h1> <br />1,325 Unknown <br />505 Root <br />17 adm etc.... </body> </html>
What I currently do is save the file into a variable, and put that variable into the html like so:
file=$(cat finalo) #file name is finalo #print to console echo " <html> <body><h1>Failed Login Re...</h1> <br />$file </body> </html>"
The output display's the entire file contents on one
html <br />. My question is how can I get each line in the file to print on each
I have tried reading each specific line of the file, saving that into a variable, and then using that variable on each
<br /> line like so:
line1=$(sed -n '1p' < finalo) line2=$(sed -n '2p' < finalo) line3=$(sed -n '3p' < finalo)
<html> <body><h1>Failed Login Report</h1> <br />$line1 <br />$line2 <br />$line3 etc...
This solution gives me the correct output, however, aside from this solution being messy, a major flaw exists if the file has a different amount of lines than the ones hard coded, it will not display.
Any help would be appreciated! This is homework btw.