shell script output in HTML or with table like results

Hello,
Currently i have a ksh script which will disply the results in plain text format.
I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html or excel format and send that content as email.
Please help me how i can do that.

Thanks in advance
Sateesh

You can simply add html tags in your echo statements.
Don't forget to add echo statements for header and footer.
If you use variables for the tags, you can choose between plain text or html by setting or not the variables.

1 Like

There are may ways to accomplish that.

One way would be like frans already suggested, I fully agree with him.
One could also afterwards create a html with appropriate awk/sed commands from the plain source file.
Also the html way guarantees that your file can be constructed pretty fast and you can read it on almost every plattform with an internet browser.

Another way would be to do that with Perl + the appropriate module called Spreadsheet:WriteExcel.
But in this case you should be very familiar with Perl. And the target machines would of course need Excel or similar application to read it.

Than there's another way, doing it with fprint and escape sequences.
Disadvantage: the colors can only be seen on UNIX(-like) systems, when concatenated.
If one edits that file he will not see any colors, but many many escape sequences, which will screw up the actual content.
The file cannot be viewed on default M$ systems. Don't know for MAC.

The previous fprint way can also be done with Perl and Term::ANSIColor The disadvantages remain the same.

1 Like