The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mailx mike509123 Linux 4 2 Weeks Ago 11:02 AM
mailX anumkoshy Shell Programming and Scripting 4 08-25-2007 09:08 AM
mailx error message : mailx: NUL changed to @ BG_JrAdmin UNIX for Dummies Questions & Answers 2 12-01-2005 06:27 AM
Help with mailx ssmith001 UNIX for Dummies Questions & Answers 1 09-02-2005 03:20 PM
mailx to to Dl sm321 Shell Programming and Scripting 1 07-16-2004 05:21 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: May 2008
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
mailx

We are using mailx to send email alerts. On occasions, it is updating our Distribution list with the mesage content.

The following is the relevant portion of the script :-
Code:
MAILGROUP=`more $MDS/feeds/alerts/distribution.lst`
export MAILGROUP
echo " " | mailx -s "MDS Alert - Refresh Complete" $MAILGROUP
The following is the distribution.lst :-

<email addresses>
From mis Wed Apr 30 10:20:07 2008
To: ::::::::::::::, <email addresses>
Subject: MDS Alert - Refresh Complete
Content-Length: 2

Note: I have replaced the list of email addresses with <email addresses>

Any ideas why the Distribution List is being updated and how to stop it happening ?

Thanks,
Paul.

Last edited by Yogesh Sawant; 05-14-2008 at 04:09 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,253
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Why are you using more to read the list? Could it be adding something which is interpreted by mailx as an instruction to write to the list file (if I interpreted your problem description at all correctly)? Just use cat instead, and/or protect the file so that it cannot be written to by the user running the script.
Reply With Quote
  #3 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: May 2008
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
more and cat seem to do the same thing (I did a quick test).
I also tried to remove the write access to the distribution list, but the scripts failed to send the email.
Reply With Quote
  #4 (permalink)  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,253
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
It's just weird to use more because it's intended for interactive use, it's a human-friendly interface for when cat is cumbersome for humans to use.

The shell script, as posted, should absolutely not care whether or not it has write access to the file. There is more to this than you are revealing, I'm afraid.

Replacing more with cat on the freak theory that more sometimes prints something which causes the file it's reading to be corrupted when you run it inside backticks is the best I can offer at this point, sorry.
Reply With Quote
  #5 (permalink)  
Old 05-14-2008
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Quote:
Originally Posted by Paul Byrne View Post
We are using mailx to send email alerts. On occasions, it is updating our Distribution list with the mesage content.

The following is the relevant portion of the script :-
Code:
MAILGROUP=`more $MDS/feeds/alerts/distribution.lst`
export MAILGROUP
echo " " | mailx -s "MDS Alert - Refresh Complete" $MAILGROUP
The following is the distribution.lst :-

<email addresses>
From mis Wed Apr 30 10:20:07 2008
To: ::::::::::::::, <email addresses>
Subject: MDS Alert - Refresh Complete
Content-Length: 2

Note: I have replaced the list of email addresses with <email addresses>

Any ideas why the Distribution List is being updated and how to stop it happening ?

Thanks,
Paul.

Hey,
Subject=Subject of mailing
MAIL_RECIPIENTS=xyz@abc.com
cat FILENAME1 | mailx -s "$Subject" $MAIL_RECIPIENTS


You can try this !
Thanks
Varun.
Reply With Quote
  #6 (permalink)  
Old 05-19-2008
Registered User
 

Join Date: May 2008
Posts: 3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Hi,

Thanks a lot for all your comments.
Replacing more with cat seems to have resolved the problem.
It was a strange one because more was not causing a problem when being run from the server. However, our mainframe kicks off the server script and the problem was only happenning then.

Again, thanks a lot.
Paul.
Reply With Quote
  #7 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: May 2008
Posts: 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
help with mail command

Hi!! I am trying to write a script that will send mail with a fixed content to email addresses fetched from a db2 table. I want the mail to appear with To, From, Cc and Subject Headers. Any idea how to do it.

This is what I have been trying:

db2 -x "SELECT USER_EMAIL_ID FROM <table_name> WHERE (LST_LOGIN_TS + 30 DAYS) >= TimeStamp (Current TimeStamp)" >mailing_list

mailing_list1=$(cat mailing_list | tr -s ' ' | tr '\n' ',' | sed 's/,$//')


cat body | mail -r "xyz@yahoo.com" -c abc@yahoo.com -s "Account Deactivation." $mailing_list1

#body is the name of the file that contains tha actual body of the mail to be sent.


But I am not sure of I can hardcode tha name of the sender using the -r option as I have done above. Also I am not sure if the names of sender, receipients, subject will appear as To:, From: and Subject: Headers in the mail. Any help will be appreciated.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
"inappropriate ioctl for device" 421 service not available, remote server has closed connection ^m autosys awk trim bash eval bash exec bash for loop boot: cannot open kernel/sparcv9/unix close_wait command copy/move folder in unix curses.h cut command in unix dead.letter find grep find null character in a unix file grep multiple lines grep or grep recursive grep unique inappropriate ioctl for device logrotate.conf lynx javascript mailx attachment mget mtime perl array length ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp batch sftp script snoop unix stale nfs file handle syn_sent tar exclude unix unix .profile unix com unix forum unix forums unix interview questions unix mtime unix simulator unix.com vi tab size vi+substitute+end+of+line+character while loop within while loop shell script


All times are GMT -7. The time now is 12:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101