Arranging the command output into an html table format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Arranging the command output into an html table format
# 1  
Old 09-11-2017
Arranging the command output into an html table format

Hi,
I need to format a command output for the beolow command:

Code:
runmqckm -cert -list -db $MQ_KDB -pw $PASSWD -expiry $EXP | grep -v "Certificates in database"

The output will be:
Code:
"ABC - cert name"
       From: Tuesday, May 25, 1999 11:09:40 AM CDT To: Saturday, May 25, 2019 11:39:40 AM CDT
   XYZ - cert name
       From: Tuesday, March 29, 2016 4:44:09 PM CDT To: Thursday, March 29, 2018 4:44:09 PM CDT


I need to format the above output into the below html table with the below columns,
Code:
       Server Name     Certificates Expiry < 90?     Certificate Name     Expiry Date (To: xxxx)

The example of the table is as below:
Code:
ServerName     CertsExpiry?     CertName     ExpiryDate 
server1     YES     cert1.com      Thu Sep 21 10:16:58 CDT 2017 
server2     YES     cert2.com      Thu Sep 21 09:56:57 CDT 2017

Can you please advise how to format the above output of the command?.

Thanks,
bdpl


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 09-12-2017 at 05:43 AM.. Reason: Added CODE tags.
# 2  
Old 09-12-2017
What have you tried? Please show us your code, and we can help you get it working.
# 3  
Old 09-12-2017
Quote:
Originally Posted by jim mcnamara
What have you tried? Please show us your code, and we can help you get it working.
Here is the code snippet what I am trying to play. I see the code is capturing for the first line of output but not for the 2nd line of the output.

Code:
typeset OLDIFS=$IFS
IFS='
'
set -A xy `runmqckm -cert -list -db $MQ_KDB -pw $PASSWD -expiry $EXP | sed '1n;N;N;N;s/\n/-/g' | grep -v "Certificates in database"`
m=0
for j in ${xy[@]}
do
CERT_NAME=`echo ${xy[$m]} | cut -d "-" -f 1`
FROM_DATE=`echo ${xy[$m]} | awk -v FS="(From:|To:)" '{print $2}'`
TO_DATE=`echo ${xy[$m]} | awk -v FS="(To:|-)" '{print $2}'`

echo "<tr><td> $QM </td> <td style="background-color:red"> YES </td><td> $CERT_NAME </td> <td style="background-color:red">  $TO_DATE </td> </tr>" >> SSLExpiryCheck.html

let m=$m+1
done
typeset IFS=$OLDIFS
echo "</table></body> </html>" >> SSLExpiryCheck.html

The content of the file 'SSLExpiryCheck.html' is:
HTML Code:
<html> <body> <h1> Certificates expiring in the next 90 days on server1: QM1.kdb</h1>
<table border=1> <tr> <th style=background-color:orange> Server Name </th> <th style=background-color:orange> Certificates Expiry < 90? </th><th style=background-color:orange> Certificate Name </th> <th style=background-color:orange> Expiry Date </th> </tr>
<tr><td> QM1 </td> <td style=background-color:red> YES </td><td>    "Entrust.net Secure Server Certification Authority" </td> <td style=background-color:red>         From: Tuesday, May 25, 1999 11:09:40 AM CDT  </td> </tr>
</table></body> </html>
Whereas the actual output of the command is:
Code:
runmqckm -cert -list -db QM1.kdb -pw xxxx -expiry 700 | sed '1n;N;N;N;s/\n/-/g' | grep -v "Certificates in database"
   "Entrust.net Secure Server Certification Authority"-       From: Tuesday, May 25, 1999 11:09:40 AM CDT To: Saturday, May 25, 2019 11:39:40 AM CDT-   ibmwebspheremqqm1-       From: Tuesday, March 29, 2016 4:44:09 PM CDT To: Thursday, March 29, 2018 4:44:09 PM CDT

I dont see the entries for the - ibmwebspheremqqm1 expiry details in SSLExpiryCheck.html output file.

Please advise whether I am missing anything. Thanks.
# 4  
Old 09-13-2017
Give people a chance to understand your problem. None of the sample data given in post#1 or #3 do match each other, and the code you provided doesn't help either. For instance, your data from runmqckm has one line only, as does the HTML table. As your verbal description is far from being clear, and code and data don't allow conclusions on how to proceed, why don't you start over and provide
- your system's info like OS, shell, tools and their versions.
- a clear description of the problem.
- basic data like the unmodified output of the runmqckm program.
- the target (desired) output (matching the input data!).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Need the output in the mentioned Table format

Hi Friends, I have the script output like below: Script Output: ----------------------------------------------------------------------- Details of the Client: ----------------------- name: server1; save set: All; ... (3 Replies)
Discussion started by: akmani
3 Replies

3. Shell Programming and Scripting

Output in table format

I have one script which generate file called report.txt having following output parameter_name status comment banking ok NA finance 30% hike NA Loan_department ok 20% HR_Group defaulters Ajay I wanted to convert this file into tabular form. You can see each line contain 3 words and... (7 Replies)
Discussion started by: Nakul_sh
7 Replies

4. Shell Programming and Scripting

Html output in correct format

Hi, I am running two scripts as below. In Script 1 i am getting correct output in proper HTML format while in script 2 i am not getting output in mail and only html code is getting printed.I want to get the output of script 2. Please guide. 1.IFILE=/home/home01/Report.csv if #Checks... (7 Replies)
Discussion started by: Vivekit82
7 Replies

5. Shell Programming and Scripting

[Solved] Shell script output in HTML or with table like results and mail

Hello, Currently i have a 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 and send that content as email. Please help me how i can do that. I am using... (10 Replies)
Discussion started by: joy lobo
10 Replies

6. Shell Programming and Scripting

Arranging Haphazard output in readable format

Dear Friends, Need your help once again. I have a sql to download output in pipe separated format. Due to that output looks haphazard. E.G. $cat output.temp 123|456|789|0 67345123||3455|1 7124563|432343414||345324 By any was can we arrange it in tabular format for better... (4 Replies)
Discussion started by: anushree.a
4 Replies

7. Shell Programming and Scripting

convert the output in table format

Hi All, I have a output like below values val1=test.com val2=10.26.208.11 val3=en1 val4=test-priv1.com val5=192.168.3.4 val6=en2 val7=test-priv2.com val8=192.168.4.4 val9=en3 val10=test-vip.com val11=10.26.208.9 val12=$val3 I want to convet this output values into below... (1 Reply)
Discussion started by: kamauv234
1 Replies

8. 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

9. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: kotasateesh
2 Replies

10. 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
Login or Register to Ask a Question