Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Convert Txt file to HTML table and email Post 302966020 by drl on Saturday 6th of February 2016 11:32:52 AM
Old 02-06-2016
Hi.

I have used utility t2t for years to solve such problems. Here's a demonstration:
Code:
#!/usr/bin/env bash

# @(#) s1       Demonstrate utility to produce HTML tables, t2t.
# http://www.scholnick.net/t2t

# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
LC_ALL=C ; LANG=C ; export LC_ALL LANG
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && $C t2t

FILE=${1-data1}
SCR=f1

pl " Input data file $FILE:"
cat -A $FILE

# Change multiple spaces to TABs:
sed 's/   */\t/g' $FILE > $SCR
pl " Modified input file $SCR:"
cat -A $SCR

pl " Results, output file is ${SCR}.html:"
# Below is for single spaces as delimiters.
# t2t --delim " " --squeeze --header --overwrite $FILE
t2t --header --overwrite $SCR

exit 0

producing:
Code:
$ ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution        : Debian 8.3 (jessie) 
bash GNU bash 4.3.30
t2t 7.3.1

-----
 Input data file data1:
Application Name      Application Status$
Application 1              Open$
Application 2              Open$
Application 3              Closed$
Application 4              Open$

-----
 Modified input file f1:
Application Name^IApplication Status$
Application 1^IOpen$
Application 2^IOpen$
Application 3^IClosed$
Application 4^IOpen$

-----
 Results, output file is f1.html, see attachment

The link for t2t is in the comments of the script.

Best wishes ... cheers, drl
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Format txt file as html table

I have a short time to solve a problem, so I need some help. I've searched the forum, but I couldn't find a solution to my problem. I made a script to filter some text and now I have a new requirement to make it available as html table. Problem is that I more than one files with different set... (2 Replies)
Discussion started by: tetreb
2 Replies

2. Shell Programming and Scripting

Is it possible to convert text file to html table using perl

Hi, I have a text file say file1 having data like ABC c:/hm/new1 Dir DEF d:/ner/d sd ...... So i want to make a table from this text file, is it possible to do it using perl. Thanks in advance Sarbjit (1 Reply)
Discussion started by: sarbjit
1 Replies

3. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

4. UNIX and Linux Applications

Ssmtp -t < /path/to/the/message.txt (How to format message.txt for html email)

ssmtp has been running well under Kubuntu 12.04.1 for plain text messages. I would like to send html messages with ssmtp -t < /path/to/the/message.txt, but I cannot seem to get the message.txt file properly formatted. I have tried various charsets, Content-Transfer-Encoding, rearranging the... (0 Replies)
Discussion started by: Ronald B
0 Replies

5. Shell Programming and Scripting

Need to convert output.txt into html file

I have output.txt file generated through shell scripts which need convert in tabular format using html can you please help me output.txt Token State Date1 Date2 Description Name 34567 open 27/06/13 28/06/13 ... (5 Replies)
Discussion started by: vijay_rajni
5 Replies

6. Shell Programming and Scripting

SQL query output convert to HTML & send as email body

Hi , I have a sql query in the unix script ,whose output is shown below.I want to convert this output to HTML table format & send email from unix with this table as email body. p_id src_system amount 1 A 100 2 B 200 3 C ... (3 Replies)
Discussion started by: jagadeeshn04
3 Replies

7. Shell Programming and Scripting

HTML table in email body using C Shell

I am using Sun Solaris ver. 5.10 and trying to send an HTML table in email body using mail command in C shell script. I tried following commands:- #1 mail -m "MIME-Version: 1.0;Content-type:text/html;charset=UTF-8" receiver@mail.com < file.html #2 mail -m "Content-type: text/html;" -s "This... (4 Replies)
Discussion started by: jnrohit2k
4 Replies

8. Shell Programming and Scripting

Regarding guidance related to HTML table in email body

Hello All, I have a query here. I am sending an HTML table(which I am creating it by a call to REST API, in a LINUX box) and from there I have to send it into an email. So following are the poins on same: As data is not static so it is writing Dynamic data and creating HTML file. There is... (9 Replies)
Discussion started by: RavinderSingh13
9 Replies

9. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

10. Shell Programming and Scripting

Postgre Query results as Email HTML table

Hello, I'm trying to send email from Greenplum query results as HTML table with status Red/Green Select Server, Last_Date from Table; Results Server, Last_Date Prod, 2018-04-09 Final email Output in HTML format Server Status LastDate Prod GREEN(BOX) 2018-04-09 (if... (2 Replies)
Discussion started by: krux_rap
2 Replies
CGI::Application::Plugin::DBIProfile(3pm)		User Contributed Perl Documentation		 CGI::Application::Plugin::DBIProfile(3pm)

NAME
CGI::Application::Plugin::DBIProfile - DBI profiling plugin SYNOPSIS
# Set env in apache or in perl. $ENV{DBI_PROFILE} = '2/CGI::Application::Plugin::DBIProfile::Driver'; use CGI::Application::Plugin::DevPopup; use CGI::Application::Plugin::DBIProfile; The rest of your application follows ... INSTALLATION
To install this module, run the following commands: perl Makefile.PL make make test make install DESCRIPTION
CGI::Application::Plugin::DBIProfile provides popup (using CAP::DevPopup if available) holding DBI Profile information (see DBI::Profile, DBI::ProfileDumper). It will output both graphed output and a DBI::ProfileDumper report. CONFIGURATION
To enable, set the DBI_PROFILE environment variables. For example in apache config for cgi SetVar DBI_PROFILE 2/CGI::Application::Plugin::DBIProfile::Driver SetVar CAP_DBIPROFILE_EXEC 1 in apache config for mod_perl PerlSetVar DBI_PROFILE 2/CGI::Application::Plugin::DBIProfile::Driver PerlSetVar CAP_DBIPROFILE_EXEC 1 in your CAP module BEGIN { $ENV{DBI_PROFILE} = '2/CGI::Application::Plugin::DBIProfile::Driver'; $ENV{CAP_DBIPROFILE_EXEC} = 1; } If you disable it, be sure to unset the DBI_PROFILE env var, as it will continue to accumulate stats regardless of the setting of CAP_DBIPROFILE_EXEC, you just won't see them. MODES OF OPERATION It has two modes of opperation; per-request or per-process. In a CGI environment, there is no difference. per-request - this is the default. per-process - set the following env var to a true value. CAP_DBIPROFILE_PERPROCESS 1 Under mod_perl, the per-request setup will show the DBI Profile specific to each page hit. The per-process setup will show the DBI Profile that has accumulated for the life of the apache process you are hitting. Please note, running under the per-process setting can cause your memory usage to grow significantly, as the profile data is never cleared. GRAPHING PLUGINS The default graphing module is CGI::Application::Plugin::DBIProfile::Graph::HTML, which generates a minimal inline HTML graph. To change which graphing plugin is used, it's just another environment variable (no need to set this if you like the default). CAP_DBIPROFILE_GRAPHMODULE Your::Graph::Module::Name Please see CGI::Application::Plugin::DBIProfile::Graph::HTML for information on writing new graph modules. TODO
Tests. None exist at this time. Other graphing plugins (Plotr, Open Flash Chart, GraphML using Graph::Easy). Add checks to be sure $dbh->{Profile} isn't disabled (probably better in ::Driver). REQUIREMENTS
Data::JavaScript IO::Scalar HTML::Template Optional: o GD::Graph For CGI::Application::Plugin::DBIProfile::Graph::GDGraphInline support. o SVG::TT::Graph For CGI::Application::Plugin::DBIProfile::Graph::SVGTT support. o HTML::BarGraph For CGI::Application::Plugin::DBIProfile::Graph::HTMLBarGraph support. SEE ALSO
CGI::Application CGI::Application::Plugin::DevPopup CGI::Application::Plugin::DBIProfile::Data CGI::Application::Plugin::DBIProfile::Driver CGI::Application::Plugin::DBIProfile::Graph::HTML CGI::Application::Plugin::DBIProfile::Graph::HTML::Horizontal CGI::Application::Plugin::DBIProfile::Graph::HTMLBarGraph CGI::Application::Plugin::DBIProfile::Graph::GDGraphInline CGI::Application::Plugin::DBIProfile::Graph::SVGTT SPECIAL THANKS
To Sam Tregar, for the original codebase on which this was based, and DBI::ProfileDumper itself. AUTHOR
Sam Tregar, C<< <sam@tregar.com> >> Joshua I Miller, C<< <unrtst@cpan.org> >> BUGS
Please report any bugs or feature requests to bug-cgi-application-plugin-dbiprofile@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Application-Plugin-DBIProfile <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI- Application-Plugin-DBIProfile>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. COPYRIGHT &; LICENSE Copyright 2007 Joshua Miller, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2011-11-10 CGI::Application::Plugin::DBIProfile(3pm)
All times are GMT -4. The time now is 03:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy