How to generate html reports through LINUX Scripting?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to generate html reports through LINUX Scripting?
# 1  
Old 04-06-2012
How to generate html reports through LINUX Scripting?

Hi All,

I am trying to generate a weekly HTML report using LINUX Scripting. This will have record counts of some files. (like below)

Code:
touch path/filename.html
echo  "Weekly Summary Report for Business Date : $P_BUS_DT">path/filename.html
export A1=`cat path/filename1.txt |wc -l`
echo  "A1 Groups : $A1">>path/filename.html
export A2=`cat path/filename2 |wc -l`
echo  "A2 Groups : $A2">>path/filename.html
etc...

But, this is generating a one line report like below
A1 : 100 A2:200

I want to generate it in 2 lines,
A1:100
A2:200

Is there a way I can generate html file in this way ?

Any help/thoughts will be helpful to resolve this issue.

Thanks much
Freddie

Last edited by joeyg; 04-06-2012 at 01:54 PM.. Reason: Please wrap code and data in CodeTags
# 2  
Old 04-06-2012
Wondering about LF/CR issues

Can you:
Code:
od -bc filename.html

and post the result here?
(Remember to wrap the output with CodeTags)
# 3  
Old 04-06-2012
How to generate html reports through LINUX Scripting

Hi Joey,

Thanks a lot for your quick response. Here s what I could see when i did an od -bc filename.html.

I am sorry if pasting the output will cause any issues, I am not sure how I can add code tags to the output. Smilie

Code:
0000000 103 120 115 107 040 127 145 145 153 154 171 040 123 165 155 155
          C   P   M   G       W   e   e   k   l   y       S   u   m   m
0000020 141 162 171 040 122 145 160 157 162 164 040 146 157 162 040 102
          a   r   y       R   e   p   o   r   t       f   o   r       B
0000040 165 163 151 156 145 163 163 040 104 141 164 145 040 072 040 015
          u   s   i   n   e   s   s       D   a   t   e       :      \r
0000060 012 124 157 164 141 154 040 111 156 151 164 151 141 154 040 123
         \n   T   o   t   a   l       I   n   i   t   i   a   l       S
0000100 165 163 160 145 143 164 163 040 072 040 063 061 071 061 060 064
          u   s   p   e   c   t   s       :       3   1   9   1   0   4
0000120 015 012 115 122 103 040 061 040 107 162 157 165 160 163 040 072
         \r  \n   M   R   C       1       G   r   o   u   p   s       :
0000140 040 063 060 015 012 115 122 103 040 110 040 107 162 157 165 160
              3   0  \r  \n   M   R   C       H       G   r   o   u   p
0000160 163 040 072 040 060 015 012 104 165 160 154 151 143 141 164 145
          s       :       0  \r  \n   D   u   p   l   i   c   a   t   e
0000200 040 122 145 143 157 162 144 163 040 072 040 060 015 012
              R   e   c   o   r   d   s       :       0  \r  \n
0000216

Thanks in advance,
Freddie

Moderator's Comments:
Mod Comment Please use code tags. Video tutorial on how to use them

Last edited by Scrutinizer; 04-06-2012 at 03:43 PM..
# 4  
Old 04-08-2012
Hi Joey,

Can you lpls et me know your thoughts on this.

Thanks Much
Freddie
# 5  
Old 04-08-2012
You need to generate a complete HTML document. Check out the tutorial here: HTML Tutorial

In short you need something along these lines:

Code:
(
  printf "<html>\n<head>\n<title>doument title</title>\n</head>\n<body>\n"
  echo  "Weekly Summary Report for Business Date : $P_BUS_DT"
  A1=`wc -l <path/filename1.txt `
  echo  "A1 Groups : $A1 <break>"
  A2=`wc -l <path/filename2 `
  echo  "A2 Groups : $A2"
  printf "</body>\n</html>\n"
) >path/filename.html

You'll also need to read up on how to properly format your output. For instance, if the output of any of your commands contains a greaterthan symbol (>) for instance, you'll need to convert it to a proper representation so that it is not interpreted by the browser as a part of HTML syntax.

If that's too much, then if you create a file with a .txt extention, most browsers render that as though it were contained in a complete HTML document with <pre> and </pre> tags around it.

Last edited by agama; 04-08-2012 at 10:43 PM.. Reason: removed useless uses of cat that I didn't catch in the original post
# 6  
Old 04-09-2012
IMO, before an inexperienced coder attempts to generate an HTML report from system commands, they should first create a script to generate a proper "Hello World" HTML page.

If you can create a "Hello World" HTML page, then it would be easy to then add more features, like output from a system command, etc.
# 7  
Old 04-09-2012
Thanks Agama & Neo for your inputs.

I will try creating a simple HTML page.

In the meantime, currently I am creating this report as .rtf extension as all the lines in the output file was coming as one single line.(I have attached it for your reference). I can create this report as .txt & convert it to html through a simple (mv *.txt to *.html) command. But wondering whether there is a way to get the output in multiple lines through some simple workaround rather than going with the HTML tags etc.

Thanks much
Freddie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX/Linux help in concatenation of multiple reports

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

2. Shell Programming and Scripting

Script to generate HTML output format listing like orasnap

Hi, Is there any UNIX scripts out there that generates a listing output of some sort similar to OraSnap At the moment, I have a script that I run on multiple servers that has multiple databases and just querying the database sizes of those databases. It generates a text files that contains... (0 Replies)
Discussion started by: newbie_01
0 Replies

3. Shell Programming and Scripting

Generate sql statement using shell scripting

Can anyone please assist me? I have attached 2 input files and one output file. I need to generate the sql update statements using the above 2 input files. if inputfile2 has 5 rows, then we should generate 5 update statements because column1 is unique. inputfile1 and inputfile2 may contain more... (10 Replies)
Discussion started by: vinus
10 Replies

4. Shell Programming and Scripting

How to generate HTML page from UNIX script out-put?

Hi All. This my first post to this forum, and i assuming it will be best out-of all. I am quite new to Unix scripting so please excuse me for any silly questions - I am trying to create on Unix script in which it telnet to my server, check the connectivity of the server and then it... (2 Replies)
Discussion started by: HHarsh
2 Replies

5. Shell Programming and Scripting

Script To Generate HTML output

Hello All, I need help here with a script. I have a script here which generates a html output with set of commands and is working fine. Now i want to add a new command/function which would run on all the remote blades and output should be included in this html file. Here is the script ... (2 Replies)
Discussion started by: Siddheshk
2 Replies

6. Shell Programming and Scripting

Generate a Execution time reports using log files.

Hi Experts, I am having a requirement, where i need to generate a report of the execution time of all the processes. All the processes generate the log files in a log directory and I can get the execution time from the log files. like below is the log file. /home/vikas/log >ls -l... (2 Replies)
Discussion started by: k_vikash
2 Replies

7. Shell Programming and Scripting

generate tabular output from an input text file in unix shell scripting

Hi, I have the output (as below) which i want it to be in a table. For e.g. space utilization in PSE on path /logs is 0% space utilization in PSE on path /logs/tuxedo/tuxlsp is 16% space utilization in PSE on path /ldvarlsp/lsp/log is 37% space utilization in PSE on path /home is 6%... (7 Replies)
Discussion started by: pkbond
7 Replies

8. UNIX and Linux Applications

Installation of Oracle Reports 6i on Linux

Hi, We are planning for a report generation program in Linux.For that we are planning to use Oracle reports 6i on linux. Could anybody please confirm if the Oracle 6i reports are compatible on Linux (0 Replies)
Discussion started by: Pavan Pusuluri
0 Replies

9. Shell Programming and Scripting

Generate report in HTML file from Oracle DB

Hi Team, I need a suggestion/comments for my below requirement. I have a procedure which performs some DDL operations & loads data into a Oracle table. This status contains Audit data. What i wanted to do is, once the procedure is completed (daily), shell script should retrive the data from the... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

10. Shell Programming and Scripting

how to generate html file using script?

Hi Friends I have an requirement that i need to generate html file using script. and the script output shold keep adding to that html file like tablewise. can anyone please help me out in this. thanks Krish. (2 Replies)
Discussion started by: kittusri9
2 Replies
Login or Register to Ask a Question