mailx command


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users mailx command
# 1  
Old 02-02-2009
mailx command

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

echo "" | mailx -s "$subject" ayisha.ikbal@abbott.com

in subject of the mail, I am only getting Early view data mart build completed on and not the value of $week_end_dt...

where m i making the mistake...
ITS VERY URGENT...
plz suggest ASAP...

thanks in advance.

Last edited by Jalkukdi@10; 02-03-2009 at 05:06 AM..
# 2  
Old 02-03-2009
Hi,
Which particular flavour of Unix are you running?
# 3  
Old 02-03-2009
ok, looking at what you have put, it seems your problem lies with the quotes used for your subject variable.

I have replicated below

# week_end_dt="20090201"
# echo $week_end_dt
20090201


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

I have tested this

# mailx -s "$subject" myemail@someplace.com
hello world
EOT


and the mail I received

From: Super-User [mailto:root@server.someplace.com]
Sent: 03 February 2009 12:28
To: mymail@someplace.com
Subject: Early view data mart build complete on 20090201


hello world


Hope this helps

Last edited by Revo; 02-03-2009 at 08:39 AM.. Reason: can't spell :)
# 4  
Old 02-04-2009
HI,

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.

Waiting for your reply.

I am using Korn shell
# 5  
Old 02-04-2009
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


Thanks

Last edited by Revo; 02-04-2009 at 02:20 PM..
# 6  
Old 02-05-2009
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"


echo "" | mailx -s "$subject" abc@xyz.com

exit 0


the output comes like this in output file:

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


and the screen shot of mail which i get is:

To abc@xyz.com

cc
Subject Early view data completed


Can u rectify this problem now?

Regards.
# 7  
Old 02-05-2009
Are you sure you show correct output?
At least the
Code:
#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
Code:
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
Code:
--> 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
Code:
echo ">${week_end_dt}<"

and copy your output here

On my system, having correct date, the mailx works as expected.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Mailx command

Using RHEL 5.5 New to using 'mailx' Was trying to check if mailx is configured. mailx command gives a list of unread mails. Now I tried to send mail using this command to a local or on network machine using mailx -s "Test2" "root@<servername>" But did not receive any message. (6 Replies)
Discussion started by: ikn3
6 Replies

2. UNIX for Dummies Questions & Answers

mailx command

Hi, I am seeing that this command is sending mail even when the nawk command in untrue ( does not have any output ). I only want it to send mail, where it goes above the threshold, and has some output. nawk -F'(MOD dn="uid=)|(DEL dn="uid=)|' '/(MOD dn="uid=)|(DEL dn="uid=)/... (2 Replies)
Discussion started by: john_prince
2 Replies

3. Solaris

mailx command

Dear all, Every time if i use mailx it is asking for entering the From Address. I want to set it in some place, So that it will take it by default whenever we send mails. Pl help on this. Regards JeganR (2 Replies)
Discussion started by: jegaraman
2 Replies

4. Solaris

Mailx command

HI All, I have an unix server , where sendmail command works for sending mail. But if i use mailx command it is not working. Is there any specific settings needed for this. Kindly help. Thanks and Regards Rj (1 Reply)
Discussion started by: jegaraman
1 Replies

5. Shell Programming and Scripting

Mailx: How to send a attachment using mailx command

Hi All, Can anyone please provide the command for sending an mail with attachment using mailx command. Thanks in Advance :) Regards, Siram. (3 Replies)
Discussion started by: Sriram.Vedula53
3 Replies

6. UNIX for Dummies Questions & Answers

mailx and -s command

How does the -s command work with mailx. I know that -s is to create a symbolic link when being used with ln but i'm not sure what the command does with mailx. Anyone?:confused: (1 Reply)
Discussion started by: kjetterman
1 Replies

7. UNIX for Dummies Questions & Answers

help on mailx command

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... (1 Reply)
Discussion started by: Jalkukdi@10
1 Replies

8. Shell Programming and Scripting

mailx command help

Dear All, I need to send a mail to a group ( the address of which is in a .profile file)..My basic mailing functionality isn't working. When i try to run mailx -s "Hello" abc@xyz.com the command does not return to the prompt an runs infinitely. Request you to help me out here along with... (3 Replies)
Discussion started by: kaushikraman
3 Replies

9. UNIX for Advanced & Expert Users

Mailx Command

Hi, mailx -s "hi" -r "abc@yahoo.com" aaa@yahoo.com<<EOF Hi, ~<!uuencode a.txt a.txt EOF the above code is sending mails, but attachment is not going instead i just get like below ~<!uuencode a.txt a.txt Thanks. (3 Replies)
Discussion started by: shahnazurs
3 Replies

10. Shell Programming and Scripting

mailx command

Hi friends, i have seen the following line in some unix shell script . can some one explain me what exactly the statement is meant for ? ========================================================= mailx -s " Master Data Transmission Report for $TODAY at $TIME " < /etc/tr/tmp/$tmplog... (5 Replies)
Discussion started by: sveera
5 Replies
Login or Register to Ask a Question