hi,
i want to pass a unix variable as the subject of the mail alongwith a string. My part of code is as below..
week_end_dt=`sqlplus -s rsamart@martdev.world/rsamart<<EOF
SET FEED OFF;
SET TIMING OFF;
SET HEADING OFF;
SET PAGESIZE 500;
SET LINESIZE 1000;
select to_char(max(week_date),'MM-DD-YYYY') from RM_EV_WEEK_LKP;
SET HEADING ON;
exit;
EOF`
subject="Early view data mart build completed on"$week_end_dt
So the variable week_end_dt holds the value of the date
# subject="Early view data mart build complete on $week_end_dt"
# echo $subject
Early view data mart build complete on 20090201
As you can see the variable subject holds the text and the contents of the variable week_end_dt.
However if you look at my example the "" enclosing the subject variable are at the beginning and end, i.e. enclosing the text and the $week_end_dt variable.
In your example, you had the quotes surrounding the text and the variable tagged on at the end
subject="Early view data mart build completed on"$week_end_dt
Whatever you said I already tried and its working fine for me too.
But the problem is that we are fetching week_end_dt from oracle. So it is assigning the oracle format to the variable. I even tried changing the MM-DD-YYYY format to MMDDYYYY to get the value as speicified by you in your eg.; but it is not working still.
can you please try out your code with some dummy value from oracle and check it out.
Hi, unfortunately I'm not that familiar with Oracle, and don't have access to it at work. I also don't have it at home. However could you provide a screen dump of the week_end_dt variable being set, followed by and echo of that variable, to see what it contains, and also the output generated by the mailx command
mailx only takes the values it has been passed, if it is not showing the week_end_dt value, then this values is not being passed to mailx for some reason, either it is not being stored properly in the variable week_end_dt, or that variable is not being passed into the string for the variable subject
Hi, i am again sending u the code and the output of that code.
week_end_dt=`sqlplus -s rsamart@martdev.world/rsamart<<EOF
SET FEED OFF;
SET TIMING OFF;
SET HEADING OFF;
SET PAGESIZE 500;
SET LINESIZE 1000;
select to_char(max(week_date),'MM-DD-YYYY') from RM_EV_WEEK_LKP;
SET HEADING ON;
exit;
EOF`
export a=$week_end_dt;
echo "this is the value of week_end_dt"
echo $week_end_dt
#subject="Early view data mart build completed on $week_end_dt"
echo "this is the value of subject"
echo $subject
echo The content is of Early view data completed "$subject"
echo The content to "$a"
cat RM_post_EV_build_alert.sh_out
this is the value of week_end_dt
03-07-2008
this is the value of subject
Early view data completed 03-07-2008
The content is of Early view data completed
03-07-2008
The content to
03-07-2008
Are you sure you show correct output?
At least the
#subject="Early view data mart build completed on $week_end_dt"
echo "this is the value of subject"
echo $subject
is not match the output
this is the value of subject
Early view data completed 03-07-2008
the 'on' is skipped.
The point of that is that, when I have tried the same, I could not get the clear date in the $week_end_dt
--> dt=$(sqlplus my_name/cur_pass@db_name <<EOT
> SET FEED OFF;
> SET TIMING OFF;
> SET HEADING OFF;
> SET PAGESIZE 500;
> SET LINESIZE 1000;
> select to_char(sysdate,'MM-DD-YYY') from dual;
> quit
> EOT
> )
-->
-->
-->
--> echo $dt
SQL*Plus: Release 9.2.0.6.0 - Production on Thu Feb 5 13:20:09 2009 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production With the Partitioning option JServer Release 9.2.0.6.0 - Production SQL> SQL> SQL> SQL> SQL> SQL> 02-05-009 SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production With the Partitioning option JServer Release 9.2.0.6.0 - Production
As you can see the sqlplus displays some more staff.
Try to get the date again and check it with
echo ">${week_end_dt}<"
and copy your output here
On my system, having correct date, the mailx works as expected.
Those are the ASCII representations of the text. You can look up the ASCII table, but 48 is a "0" & 51 is a "3" & 45 is a "-" and so on. The 10 is a line-feed.
I am curious if there are some control characters like tab or carriage-return or something else that is somehow part of the string.
The value of week_end_date is coming properly. There is no problem in echoing that. The problem is that value is not displayed in the subject of the mail. On the contrary if I specify $week_end_date in the text part of the mail then it is displaying it properly. I am writing the code again with proper output. kindly check the same
the ouptut is
and the mail which i get has subject as shown below
Hope these things will help u all to understand now.
Are you reading reply to your questions?
Why you did not make what you have been asked?
People spend time to get your problem, try it, think about it, replay you, but you do not care, repeating the same and, even, 'asap'!
I am sure you have 'lf' in your data and if you would do what I asked you to do or, even better, apply the 'od' command as it was advised, you would see it.
I do not see a reason to spend time for this thread and it is my last post here.
You can continue just to do the same and repeat it again and again. Good lock!
For your kind information i have already tried your method i.e. ">${week_end_dt}<" to include in the subject. but its not working. I dont know why. probably it might be working for u. For the same reason i am repeating my code in this thread to get u all the better idea. Regarding the 'od' command i dint get time to check thru it. i was in hurry when i lastly posted.
By the way thanks for your precious time. I am really glad to have ur suggestions.
I got the solution to my question. Sometimes we think too complex solutions for the simple questions.:p:b:
The subject just required to be assigned with echo command to get it displayed in the mail.
subject=`echo Early view data mart build completed on $week_end_dt`
This resolves the problem.
Thanks for your valuable efforts.
No. It is nothing do with how the oracle assigns the value to the variable. The thing which i got to learn is that you cannot pass a variable directly into the subject of the mail. On the contrary if you pass the variable as an executable command then it works properly as in this case.