Please help in populating output in table using shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help in populating output in table using shell scripting
# 1  
Old 02-20-2015
Please help in populating output in table using shell scripting

Below is my code where i tried using table tag to print out put in table but its not working

Code:
#!/bin/ksh

#[[ -f ./.profile ]] && . ./.profile 2>/dev/null

if test -f '.profile'; then . ./.profile; fi;

#. .profile

LOG_DIR=/app/rpx/jobs/scripts/just/logs
  sendEmail()
    {
        pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7"
        (
          echo "From: $pzFrom\nTo: $pzTo\nSubject: $pzTitle${pzReplyTo:+\nReply-To: $pzReplyTo}"

              [[ -n "$pzCType" ]] && echo "Content-Type: $pzCType"

              echo
               echo "$pzMsg"
                  [[ -n "$pzFiles" ]] &&
                  echo &&
                  for pzFile in $pzFiles
                  do
                    [[ -f "$pzFile" ]] && uuencode "$pzFile" "$pzFile"
                  done

                ) | mail "$pzTo"
          }

## all pending subscriber .

pending=`sqlplus -s pag_app/abcdef@prpx1-vip.unix.gsm1900.org:7779/prpx.unix.gsm1900.org <<EOF
set feedback off;
set heading off;
set trimspool on;
set pagesize 0;
SET LINESIZE 180;

select '<tr><td>'||msisdn||'</td><td>'||status_changed_time||'</td><td>'||rate_plan_id||'</td><td>'||status||'</td></tr>' from sub
scriber where status = 'P' and status_changed_time < sysdate order by status_changed_time  desc;
EOF`

activating=`sqlplus -s pag_app/abcdef@prpx1-vip.unix.gsm1900.org:7779/prpx.unix.gsm1900.org <<EOF
set feedback off;
set heading off;
set trimspool on;
set pagesize 0;
SET LINESIZE 180;

select '<tr><td>'||msisdn||'</td><td>'||status_changed_time||'</td><td>'||rate_plan_id||'</td><td>'||status||'</td></tr>' from sub
scriber where status = 'I' and status_changed_time < sysdate order by status_changed_time  desc;
EOF`

final="Pending
    <table><tr><td>Msisdn    </td><td>      Date    </td><td>    RP Status </td></tr>
    $pending
    </table>
    Activating
        <table> <tr><td>Msisdn     </td><td>     Date   </td><td>     RP Status  </td></tr>
        $activating
        </table>"
sendEmail '' "Pending_Activating" "$final" 'ankit.gupta92@gmail.com' 'balaji.k@gmail.com' " " ' '
exit 0;

---------- Post updated at 05:23 AM ---------- Previous update was at 05:22 AM ----------

Below is the output of above

Code:
Pending
    <table><tr><td>Msisdn    </td><td>      Date    </td><td>    RP Status </td></tr>
    <tr><td>15204503281</td><td>19-FEB-15</td><td>183</td><td>P</td></tr>
<tr><td>19155404218</td><td>19-FEB-15</td><td>183</td><td>P</td></tr>
<tr><td>18329976221</td><td>19-FEB-15</td><td>179</td><td>P</td></tr>
<tr><td>16127078234</td><td>19-FEB-15</td><td>183</td><td>P</td></tr>
<tr><td>15208738121</td><td>19-FEB-15</td><td>173</td><td>P</td></tr>
<tr><td>14016880957</td><td>19-FEB-15</td><td>707</td><td>P</td></tr>
<tr><td>12525487753</td><td>19-FEB-15</td><td>173</td><td>P</td></tr>
<tr><td>12566400680</td><td>19-FEB-15</td><td>717</td><td>P</td></tr>
    </table>
    Activating
	<table> <tr><td>Msisdn     </td><td>     Date   </td><td>     RP Status  </td></tr>
	</table>
	<tr><td>17027857667</td><td>19-FEB-15</td><td>156</td><td>I</td></tr>
<tr><td>12068591961</td><td>15-FEB-15</td><td>176</td><td>I</td></tr>
<tr><td>12064460516</td><td>15-FEB-15</td><td>176</td><td>I</td></tr>
<tr><td>19544713197</td><td>31-JAN-15</td><td>156</td><td>I</td></tr>

Moderator's Comments:
Mod Comment Please stop using QOUTE tags to mark text that has never appeared before.

Last edited by Don Cragun; 02-21-2015 at 08:34 AM.. Reason: Delete inappropriate QUOTE tags.
# 2  
Old 02-20-2015
Did you know that SQLPlus supports html markup ?
Code:
set markup html on

# 3  
Old 02-21-2015
I tried set markup html on, still its not working

Code:
#!/bin/ksh

#[[ -f ./.profile ]] && . ./.profile 2>/dev/null

if test -f '.profile'; then . ./.profile; fi;

#. .profile

LOG_DIR=/app/rpx/jobs/scripts/just/logs
  sendEmail()
    {
        pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7"
        (
          echo "From: $pzFrom\nTo: $pzTo\nSubject: $pzTitle${pzReplyTo:+\nReply-To: $pzReplyTo}"

              [[ -n "$pzCType" ]] && echo "Content-Type: $pzCType"

              echo
               echo "$pzMsg"
                  [[ -n "$pzFiles" ]] &&
                  echo &&
                  for pzFile in $pzFiles
                  do
                    [[ -f "$pzFile" ]] && uuencode "$pzFile" "$pzFile"
                  done

                ) | mail "$pzTo"
          }

## all pending subscriber .

pending=`sqlplus -s pag_app/abcdef@prpx1-vip.unix.gsm1900.org:7779/prpx.unix.gsm1900.org <<EOF
set feedback off;
set markup html on;
set heading off;
set trimspool on;
set pagesize 0;
SET LINESIZE 180;

select '<tr><td>'||msisdn||'</td><td>'||status_changed_time||'</td><td>'||rate_plan_id||'</td><td>'||status||'</td></tr>' from sub
scriber where status = 'P' and status_changed_time < sysdate order by status_changed_time  desc;
EOF`

activating=`sqlplus -s pag_app/abcdef@prpx1-vip.unix.gsm1900.org:7779/prpx.unix.gsm1900.org <<EOF
set feedback off;
set markup html on;
set heading off;
set trimspool on;
set pagesize 0;
SET LINESIZE 180;

select '<tr><td>'||msisdn||'</td><td>'||status_changed_time||'</td><td>'||rate_plan_id||'</td><td>'||status||'</td></tr>' from sub
scriber where status = 'I' and status_changed_time < sysdate order by status_changed_time  desc;
EOF`

final="Pending
    <table><tr><td>Msisdn    </td><td>      Date    </td><td>    RP Status </td></tr>
    $pending
    </table>
    Activating
        <table> <tr><td>Msisdn     </td><td>     Date   </td><td>     RP Status  </td></tr>
        $activating
        </table>"
sendEmail '' "Pending_Activating" "$final" 'ankit.gupta92@gmail.com' 'balaji.k@gmail.com' " " ' '
exit 0;

Output is as below
Code:
Pending
    <table><tr><td>Msisdn    </td><td>      Date    </td><td>    RP Status </td></tr>
    <p>
<table border='1' width='90%' align='center' summary='Script output'> <tr> <td> &lt;tr&gt;&lt;td&gt;12198057608&lt;/td&gt;&lt;td&gt;21-FEB-15&lt;/td&gt;&lt;td&gt;173&lt;/td&gt;&lt;td&gt;P&lt;/td&gt;&lt;/tr&gt;
</td>
</tr>
</table>
<p>
    </table>
    Activating
	<table> <tr><td>Msisdn     </td><td>     Date   </td><td>     RP Status  </td></tr>
	<p>
<table border='1' width='90%' align='center' summary='Script output'> <tr> <td> &lt;tr&gt;&lt;td&gt;19175889670&lt;/td&gt;&lt;td&gt;21-FEB-15&lt;/td&gt;&lt;td&gt;183&lt;/td&gt;&lt;td&gt;I&lt;/td&gt;&lt;/tr&gt;
</td>
</tr>
<tr>
<td>
&lt;tr&gt;&lt;td&gt;17027857667&lt;/td&gt;&lt;td&gt;19-FEB-15&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;td&gt;I&lt;/td&gt;&lt;/tr&gt;
</td>
</tr>
<tr>
<td>
&lt;tr&gt;&lt;td&gt;12068591961&lt;/td&gt;&lt;td&gt;15-FEB-15&lt;/td&gt;&lt;td&gt;176&lt;/td&gt;&lt;td&gt;I&lt;/td&gt;&lt;/tr&gt;
</td>
</tr>
<tr>
<td>
&lt;tr&gt;&lt;td&gt;12064460516&lt;/td&gt;&lt;td&gt;15-FEB-15&lt;/td&gt;&lt;td&gt;176&lt;/td&gt;&lt;td&gt;I&lt;/td&gt;&lt;/tr&gt;
</td>
</tr>
<tr>
<td>
&lt;tr&gt;&lt;td&gt;19544713197&lt;/td&gt;&lt;td&gt;31-JAN-15&lt;/td&gt;&lt;td&gt;156&lt;/td&gt;&lt;td&gt;I&lt;/td&gt;&lt;/tr&gt;
</td>
</tr>
</table>
<p>
	</table>

Moderator's Comments:
Mod Comment Please stop using QUOTE tags to mark text that has not appeared before.

Please use CODE tags (not QUOTE tags) to display sample input and output.

Last edited by Don Cragun; 02-21-2015 at 08:48 AM.. Reason: Fix tags again. (Remove yellow code that disappears on gray background.
# 4  
Old 02-22-2015
I think you misunderstood what I was suggesting...

try this:
Code:
activating=`sqlplus -s user/passwd@host <<EOF 
set feedback off; 
set markup html on; 
set trimspool on; 
set pagesize 0; 
SET LINESIZE 180;  
select  
    msisdn, status_changed_time as date,rate_plan_id as RP ,status 
  from subscriber
  where status = 'I' 
    and status_changed_time < sysdate 
  order by status_changed_time  desc; 
EOF`

and use the resulting output as the activating table
# 5  
Old 02-23-2015
Code:
#!/bin/ksh

#[[ -f ./.profile ]] && . ./.profile 2>/dev/null

if test -f '.profile'; then . ./.profile; fi;

#. .profile

LOG_DIR=/app/rpx/jobs/scripts/just/logs
  sendEmail()
    {
        pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7"
        (
          echo "From: $pzFrom\nTo: $pzTo\nSubject: $pzTitle${pzReplyTo:+\nReply-To: $pzReplyTo}"

              [[ -n "$pzCType" ]] && echo "Content-Type: $pzCType"

              echo
               echo "$pzMsg"
                  [[ -n "$pzFiles" ]] &&
                  echo &&
                  for pzFile in $pzFiles
                  do
                    [[ -f "$pzFile" ]] && uuencode "$pzFile" "$pzFile"
                  done

                ) | mail "$pzTo"
          }

## all pending subscriber .

pending=`sqlplus -s pag_app/pass@prpx1-vip.unix.gsm1900.org:7779/prpx.unix.gsm1900.org <<EOF
set feedback off;
set markup html on;
set trimspool on;
set pagesize 0;
SET LINESIZE 180;

select msisdn, status_changed_time, rate_plan_id, status from subscriber where status = 'P' and status_changed_time < sysdate orde
r by status_changed_time  desc;
EOF`

activating=`sqlplus -s pag_app/pass@prpx1-vip.unix.gsm1900.org:7779/prpx.unix.gsm1900.org <<EOF
set feedback off;
set markup html on;
set trimspool on;
set pagesize 0;
SET LINESIZE 180;

select msisdn, status_changed_time, rate_plan_id, status from subscriber where status = 'I' and status_changed_time < sysdate orde
r by status_changed_time  desc;
EOF`

final="Pending
Msisdn      Date   RP Status
$pending
Activating
Msisdn      Date   RP Status
$activating"

sendEmail '' "Pending_Activating" "$final" 'ankit.gupta92@gmail.com' 'ankit.gupta92@gmail.com' " " ' '

When i tried as above, it just giving me tr, td tags

as below

Quote:
Pending
Msisdn Date RP Status
<p>
<table border='1' width='90%' align='center' summary='Script output'> <tr> <td>
16266939061
</td>
<td>
23-FEB-15
</td>
<td align="right">
707
</td>
<td>
P
</td>
</tr>
<tr>
<td>
19256396306
</td>
<td>
23-FEB-15
</td>
<td align="right">
717
</td>
<td>
P
</td>
</tr>
<tr>
<td>
13108173908
</td>
<td>
# 6  
Old 02-23-2015
Looks an HTML page with a perfect table to me, once it's enclosed in <html> tags...

---------- Post updated at 09:49 ---------- Previous update was at 09:46 ----------

Why don't you leave the entire text creation to your DB system with markup html on, to be on the safe side?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell output format like table

Hi, OS: Redhat 7.5 shell: Bash Wrote below script to login into oracle via shell script and trying to reset locked account..It works as expected. But I need specific output << EOF should go to target terminal not all out put running below script from ansible command line.. #!/bin/bash... (1 Reply)
Discussion started by: onenessboy
1 Replies

2. Forum Support Area for Unregistered Users & Account Problems

Creation of Oracle table through shell scripting

Hi, I am trying to create a table through shell scripting . I used a command sqlplus -s to connect to sqlplus and user as sysdba. but there is a problem in it. can anyone please solve this . #!/bin/bash $(`sqlplus -s / as sysdba <<eof create table sample (id,int); insert into sample... (1 Reply)
Discussion started by: Unregistered
1 Replies

3. UNIX for Advanced & Expert Users

How can i populate the record in to table using shell scripting?

LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( echo "From: $pzFrom\nTo: $pzTo\nSubject: $pzTitle${pzReplyTo:+\nReply-To: $pzReplyTo}" ] && echo... (1 Reply)
Discussion started by: ankit.mca.aaidu
1 Replies

4. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

5. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

6. Shell Programming and Scripting

How to update a Oracle table through shell scripting?

My Code is get_week_date() { `sqlplus -s ${DQM_SQL_LOGON}@${DQM_SID} << EOF SET ECHO OFF SET FEEDBACK OFF SET PAGES 0 SET SERVEROUTPUT ON SET VERIFY OFF SET TRIMSPOOL ON (update file_level_qc fq set FQ.DATA_FILE_NAME='Hyvee_Pharmacy_Solutions_201304_v1.txt'... (2 Replies)
Discussion started by: karthick.cho
2 Replies

7. Shell Programming and Scripting

How to get the file size and count of a table using shell scripting?

Hi there, im a beginner to the shell scripting.i trying to extract a table from a db(IMD) and i have to get the count of that table and size of the file. can you help me out how to write the shall scriping for the above query. (2 Replies)
Discussion started by: pawanmamidi
2 Replies

8. Shell Programming and Scripting

How to Add Table with Header for Shell Output

I have a Script that generates 3 columns of the result. The line script is /usr/xpg4/bin/awk -F' ' '{print $1 /t $2}' File_Name | awk -F'>' '{print $2}' | cut -d'<' -f1 | sort -rn | uniq -c The output of the Command is : Code.500 4 Input Error Code.404 ... (4 Replies)
Discussion started by: raghunsi
4 Replies

9. Shell Programming and Scripting

Create a table using shell scripting

Hi Can we create a rectangular table as i have attached in the query . This is primarily for populating the created table with data gathered . Hope I made myself clear ... Pls suggest Thanks (1 Reply)
Discussion started by: ultimatix
1 Replies

10. Shell Programming and Scripting

awk - Pre-populating an array from system command output

So, here's a scenario that requires the same logic as what I'm working on: Suppose that you have a directory containing files named after users. For awk's purposes, the filename is a single field-- something parse-friendly, like john_smith. Now, let's say that I'd like to populate an array in... (2 Replies)
Discussion started by: treesloth
2 Replies
Login or Register to Ask a Question