mailx issue -


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mailx issue -
# 1  
Old 07-23-2009
mailx issue -

Hi,

I am sending mail inside my script based on various conditions.

Here is the problem,

when there are more than one condion at a time, the mailx adds the messages into one ( at the time of the second mail)

example:

Code:
inner_fn ()
{
  if [ $a -eq 5 ]; then 
   echo "inner function mail" | mailx -s "sub2" "some1@somedomain.com"
  fi
}

outer_fn ()
{
a=5

if [ $a -lt 6 ];then
 echo "outer function mail" | mailx -s "sub1" "some1@somedomain.com"
 inner_fn
fi
}



when I run this, I receive two mails with messages & subject like below.

Quote:
1. subject is - sub1, message is - outer function mail.

2. subject is - sub2, message is

outer function mail
inner function mail.
i.e the outermail message is still there in the second mail.

how can i resolve this and what could be the reason behind this.!!!

Thanks.
# 2  
Old 07-23-2009
look at the value of 'a'

You have assigned the value of a to 5.


The condition for outer loop is 'a' should be less than 6 and condition for inner loop is 'a' should be equal to 5.


Hence both the loops are succeeding and you are getting two mails!
# 3  
Old 07-23-2009
i'm not sure but i think you need to clear you mail queue since your calling it from a sub process.

try redirecting that body of letter instead of just echoing or try putting it in a variable

Code:
inner_fn ()
{
  if [ $a -eq 5 ]; then 
   echo "inner function mail" > mail1
   mailx -s "sub2" "some1@somedomain.com" < mail1
  fi
}

outer_fn ()
{
a=5

if [ $a -lt 6 ];then
 echo "outer function mail" > mail2
 mailx -s "sub1" "some1@somedomain.com" < mail2
 inner_fn
fi
}


Last edited by ryandegreat25; 07-23-2009 at 05:45 AM..
# 4  
Old 07-23-2009
Hi,

The mail queue problem could be possible but I tried the above solution but unfortunately it didnt work.

How can I clear the mail Queue?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mailx Email Issue

Hello, I am facing an issue with email in Linux. I am using mailx command to send email. When I give invalid domain address then it is taking both sender and recipient as sender email and trying to send email. Below is my command echo -e "${EMAIL_TEXT}" | mailx -v -s "${SUBJECT}" -r... (5 Replies)
Discussion started by: yuvi
5 Replies

2. Shell Programming and Scripting

Issue with Mailx command

Hi, I am trying to send an email using mailx command in Linux terminal. Though I give invalid address it is giving response as Recipient ok and sent message. My command is here. Not sure what is wrong. Can anyone please assist? echo -e 'New User'| mailx -v -s 'New User' y@gggg.com ... (1 Reply)
Discussion started by: yuvi
1 Replies

3. Shell Programming and Scripting

Mailx attachment using uuencode issue on Outlook2013

Hello all I am on RHEL 6.4. I have been using my bash script which mails one .csv file after zipping (myfile.csv.zip)to my Lotus Notes ID. I use uuencode with mailx to do this. Here is my command - uuencode myfile.csv.zip myfile.csv.zip | mailx -s "Subject" mailid. This all works very cool. Now... (3 Replies)
Discussion started by: krsnadasa
3 Replies

4. Shell Programming and Scripting

Mailx command issue

Hi All, Im facing a problem with sending tar file via mailx command. Your help would be much appreciated. Im trying to tar a set of CSV files in a folder using the below command tar cvf Report.tar.gz *_03172016.CSV and sending this tar file using mailx command as mentioned below ... (2 Replies)
Discussion started by: anijan
2 Replies

5. Shell Programming and Scripting

Need help in an issue related to mailx

Hello, I have a file temp.txt with the below contents : Sep 9 03:04:51 adcsdp01 MAPDR2_00: Unable to open trace file adpstartarv.log. (Error 110 Resource temporarily unavailable) Sep 9 03:05:35 adcsdp01 MAPDR2_00: SAP Service ADPMR2_00 successfully started. Sep 9 03:04:51 adcsdp01... (7 Replies)
Discussion started by: rahul2662
7 Replies

6. Shell Programming and Scripting

Mailx command timeout Issue

Hi All, I have a situation where we need to send out mails from our Unix server to different mailing ids inside our scripts.The mails are working fine.But we have occasional issues where we are getting time out errors from the SMTP server while sending out mails. Command that we are using... (3 Replies)
Discussion started by: DevotedPupil
3 Replies

7. Shell Programming and Scripting

Mailx issue

Hi guys I am trying to send an email using mailx function and want the message body to appear on different lines. My code is : WT=`echo "Tapes are : $x Holder are : $y" ` echo $WT|mailx -s "Alert" xyx@abc.com I want to receive the email like this: Tapes are :2 Holders are... (2 Replies)
Discussion started by: Junaid Subhani
2 Replies

8. HP-UX

[Solved] mailx : unknown user issue

Hi all, I know this issues has been discussed multiple times, i have gone through many such discussion but unfortunately i am still not able to solve the issue being faced. I have configured the sendmail.cf with the smtp host name (Editing the entry starting with DS...) Post that restarted... (7 Replies)
Discussion started by: chpsam
7 Replies

9. UNIX for Dummies Questions & Answers

Issue with file permissions when using mailx

Hiya... I've got a script on AIX 4.2 that sends an email, with an attachment, that has always worked happily in the past and has chosen today to stop working. It now throws up an error "/tmp/Rs13492: The file access permissions do not allow the specified action" The /tmp/RsXXXXX file name... (2 Replies)
Discussion started by: phaedrus
2 Replies

10. UNIX for Dummies Questions & Answers

mailx Issue with -r flag

I've used "mailx -r return@address" before many times for automated scripts, but when I try to use it on FreeBSD, I get "mailx: illegal option -- r". Is there another version of mailx I should be using to get this to work? The full command I'm trying to run is: mailx -s "Load Results $(date... (1 Reply)
Discussion started by: superdelic
1 Replies
Login or Register to Ask a Question