LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   convert txt to 3 column html (https://www.linuxquestions.org/questions/linux-newbie-8/convert-txt-to-3-column-html-4175535911/)

aristosv 03-05-2015 10:27 PM

convert txt to 3 column html
 
I have a server sending me a plain text email every day, reporting the below parameters. Its reading them from a text file, and sending them to my email.

How can convert this to a three column html table and send that?

Code:

Sync Total: 1 directory, 4 files, 0 symlinks
---------------------------------
Host Name: host name here
---------------------------------
Group Name: group name here
---------------------------------
Disk Usage: 37%
---------------------------------
CPU Usage: 78%
---------------------------------
Memory Usage: 11%
---------------------------------
Temperature: 44.9'C
---------------------------------
Local IP: 192.168.0.115
---------------------------------
Public IP: public ip here
---------------------------------
Tunnel Port: 5001
---------------------------------
Tunnel Status:
Fri Mar 6 06:23:00 EET 2015 opening reverse tunnel from my_host_here:5001 to 127.0.0.1:22
---------------------------------

Thanks

veerain 03-05-2015 10:49 PM

What would be the column criterias(name)?

Did you tried any scripts yourself? If so post it.

vinay9 03-05-2015 11:23 PM

#a.html is output_html_file
#file.txt is the text file produced by server
oldIFS=$IFS
IFS=:
terminal=`tty`
exec<file.txt
echo "<html><head><title>forecast</title></head><body><table border=5>" >>a.html
while read line
do
set $line
echo "<tr><td>"$1"</td><td>"$2"</td></tr>" >>a.html
done
echo "</table></body></html>" >>a.html
IFS=$oldIFS
exec<$terminal

grail 03-05-2015 11:51 PM

Please use [code][/code] tags to display code or data.

So what is your issue?

veerain 03-05-2015 11:56 PM

From that file can you show an example of first row (arrangement).


All times are GMT -5. The time now is 01:12 PM.