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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I want query output to send on mail using table tag and output should be in table
# 8  
Old 02-11-2015
If you show us the SELECT statement you are now using and we can probably adjust it.

Is there a reason for having it in boxes? It will make it more difficult to use the data later on. For a report to be published, it's usual to have a comma separated file that you can read into a spreadsheet. You can graph it then, which can be much better for understanding the information you wish to convey rather that just the raw data.


Robin
# 9  
Old 02-11-2015
Is your goal to create a mail with html body that has the result of your query as content? You'll need to generate a html report first (find the documentation here) and use an appropriate content type.
If you just want the columns seperated have a look at the SQL*Plus setting colsep.
This User Gave Thanks to cero For This Post:
# 10  
Old 02-12-2015
Can you pelase help how can i bring that dotted lines on top of my row value

Code:
-----------   ----------  ---------   -
| 16612969688 | 11-FEB-15 |       707 | P |

---------- Post updated 02-12-15 at 12:18 AM ---------- Previous update was 02-11-15 at 11:40 PM ----------

Well as you said using HTML tags i tried but i thinking i am missing something

Code:
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;
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
HEAD "<TITLE>Pending</TITLE>
<STYLE types='text/css'>
<!-- BODY {background: #FFFFC6}
</STYLE>"
BODY "TEXT='#FF00Ff'"
TABLE "WIDTH='90%' BORDER='5'"

SPOOL report.html

select msisdn,status_changed_time,rate_plan_id,status from subscriber where status = 'P' and status_changed_time < sysdate order b
y status_changed_time  desc;

SPOOL OFF
EOF`

Output is as below
Code:
SP2-0734: unknown command beginning &quot;HEAD &quot;&lt;TIT...&quot; - rest of line ignored.
<br>
SP2-0734: unknown command beginning &quot;&lt;STYLE typ...&quot; - rest of line ignored.
<br>
SP2-0734: unknown command beginning &quot;&lt;!-- BODY ...&quot; - rest of line ignored.
<br>
SP2-0042: unknown command &quot;&lt;/STYLE&gt;&quot;&quot; - rest of line ignored.
<br>
SP2-0044: For a list of known commands enter HELP and to leave enter EXIT.
<br>
SP2-0734: unknown command beginning &quot;BODY &quot;TEXT...&quot; - rest of line ignored.
<br>
SP2-0734: unknown command beginning &quot;TABLE &quot;WID...&quot; - rest of line ignored.
<br>
<p>
<table border='1' width='90%' align='center' summary='Script output'> <tr> <td>
16268612580
</td>
<td>
11-FEB-15
</td>
<td align="right">
       179
</td>
<td>
P
</td>
</tr>
<tr>
<td>
17327623109
</td>
<td>
11-FEB-15
</td>
<td align="right">
       707
</td>
<td>
P
</td>
</tr>

---------- Post updated at 12:21 AM ---------- Previous update was at 12:18 AM ----------

I tried using HTML Report, i think i am missing something here

Code:
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;
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
HEAD "<TITLE>Pending</TITLE>
<STYLE types='text/css'>
<!-- BODY {background: #FFFFC6}
</STYLE>"
BODY "TEXT='#FF00Ff'"
TABLE "WIDTH='90%' BORDER='5'"

SPOOL report.html

select msisdn,status_changed_time,rate_plan_id,status from subscriber where status = 'P' and status_changed_time < sysdate order b
y status_changed_time  desc;

SPOOL OFF
EOF`

Output is below

Code:
SP2-0734: unknown command beginning &quot;HEAD &quot;&lt;TIT...&quot; - rest of line ignored.
<br>
SP2-0734: unknown command beginning &quot;&lt;STYLE typ...&quot; - rest of line ignored.
<br>
SP2-0734: unknown command beginning &quot;&lt;!-- BODY ...&quot; - rest of line ignored.
<br>
SP2-0042: unknown command &quot;&lt;/STYLE&gt;&quot;&quot; - rest of line ignored.
<br>
SP2-0044: For a list of known commands enter HELP and to leave enter EXIT.
<br>
SP2-0734: unknown command beginning &quot;BODY &quot;TEXT...&quot; - rest of line ignored.
<br>
SP2-0734: unknown command beginning &quot;TABLE &quot;WID...&quot; - rest of line ignored.
<br>
<p>
<table border='1' width='90%' align='center' summary='Script output'> <tr> <td>
16268612580
</td>
<td>
11-FEB-15
</td>
<td align="right">
       179
</td>
<td>
P
</td>
</tr>
<tr>
<td>
17327623109
</td>
<td>
11-FEB-15
</td>
<td align="right">
       707
</td>
<td>
P
</td>
</tr>

Please help if i am doing something wrong here
Moderator's Comments:
Mod Comment Please use QUOTE tags to display data that you are quoting from an earlier post; not to indicate your new comments in the current post.

Last edited by Don Cragun; 02-14-2015 at 12:52 AM.. Reason: Remove unneeded QUOTE tags.
# 11  
Old 02-12-2015
You are missing the minus signs:
Code:
...
SET LINESIZE 180;
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
HEAD "<TITLE>Pending</TITLE> -
<STYLE types='text/css'> -
<!-- BODY {background: #FFFFC6} -
</STYLE>" -
BODY "TEXT='#FF00Ff'" -
TABLE "WIDTH='90%' BORDER='5'"

SPOOL report.html
...

# 12  
Old 02-12-2015
Now i tried including '-' sign

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.gsm=1900.org:7779/prpx.unix.gsm1900.org <<EOF
set pagesize 0;
SET LINESIZE 180;
SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
HEAD "<TITLE>Pending</TITLE> -
<STYLE types='text/css'> -
<!-- BODY {background: #FFFFC6}--> -
</STYLE>" -
BODY "TEXT='#FF00Ff'" -
TABLE "WIDTH='90%' BORDER='5'"

SPOOL report.html

select msisdn,status_changed_time,rate_plan_id,status from subscriber where status = 'P' and status_changed_time < sysdate order b
y status_changed_time  desc;

SPOOL OFF
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 msisdn,status_changed_time,rate_plan_id,status from subscriber where status = 'I' and status_changed_time < sysdate order b
y status_changed_time  desc;
EOF`

final="Pending
$pending

Activating
$activating"

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

echo $final > $LOG_DIR/pending_`date +%d%m%y`.log

getting no output

i Only tried it on pending first later i can do the same on activating parrt
Moderator's Comments:
Mod Comment Please use QUOTE tags to display data that you are quoting from an earlier post; not to indicate your new comments in the current post.

Last edited by Don Cragun; 02-14-2015 at 12:53 AM.. Reason: Get rid of QUOTE tags that are not quoting previous posts.
# 13  
Old 02-12-2015
The backquote is at the wrong place:
Code:
...
## all pending subscriber .

pending=`sqlplus -s pag_app/abcdef@prpx1-vip.unix.gsm=1900.org:7779/prpx.unix.gsm1900.org <<EOF
set pagesize 0;
...

# 14  
Old 02-12-2015
You could always have a:-
Code:
SELECT ' -------------------   ----------   ---------------   -' FROM dual ;


Would that help?



Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create a file from output of vertica table query in UTF-8 format?

Hello, In my shell script, I extract table data from HP Vertica DB into a csv file using vsql -c command. But the problem is the file getting created is in binary format and hence some of the data becomes unreadable which has chinese characters as part of data. file -i filename.csv - gives... (2 Replies)
Discussion started by: Dharmatheja
2 Replies

2. Shell Programming and Scripting

Table to send mail

I have two details to send in html email, two details present in variables, Processname & date which I need to send html email in table. Column1 is Processname: Process1 & column 2 is date:16/6/16 4:55 AM I have below basic html code, how to create table in html to send mail echo "<html>" >>... (1 Reply)
Discussion started by: rozee
1 Replies

3. Solaris

SQL QUERY to Table Output

Hi I am trying to run sql query from solaris in csh script and send the output to email. Below is my sql query select p.spid,se.program seprogram, se.machine, se.username, sq.sql_text,sq.retrows from v$process p inner join v$session se on p.addr = se.paddr inner join ( select... (2 Replies)
Discussion started by: tharmendran
2 Replies

4. Solaris

How to output the prstat into table and send through email?

Hi how to send below prstat script output into table format and send through email? prstat|awk '{ if ($9 >= 5) print $0 }' (17 Replies)
Discussion started by: tharmendran
17 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

[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

7. Shell Programming and Scripting

Take Data From a table and send it through mail

Hi can anyone help me in writing a code for taking data from a table and need to send that data through mail using mail -x command.. (3 Replies)
Discussion started by: ginrkf
3 Replies

8. Shell Programming and Scripting

Mailx command - send mail as table format

I have to send a couple of rows that have been returned from a SQL query. I have written the output of the query to a file and while i try to print this in the mail body the formatting goes wrong. Intended Output in mail body: Col1 Col2 Col3 ------ ... (2 Replies)
Discussion started by: qwertyu
2 Replies

9. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

10. Shell Programming and Scripting

Arrange Data in table and send by mail

Everybody, can you tell me how express about this; we have text data file as : parameter1 Parameter2 AA 55 BB 77 . . . . . . We want to draw table for this data as attached then send as body of Email (4 Replies)
Discussion started by: xjklop2009
4 Replies
Login or Register to Ask a Question