help with grep and mailx


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help with grep and mailx
# 15  
Old 11-18-2004
There is a problem with syntax like:

tee file1 | uuencode file1 file1 | mailx X@Y.com


When uuencode has two parameters, the first is the input file and that means that uuencode will not be reading from stdin thus breaking the pipeline. At the time uuencode reads from file1, the tee program may or may not have written to it. It depends on the order in which the programs in the pipeline are launched, the number of cpu's, etc.

If you really need file1 to exist on the local system try:

tee file1 | uuencode file1 | mailx X@Y.com

if not just go with:

uuencode file1 | mailx X@Y.com

The syntax to handle the zerio length file will depend on what shell you are using.
# 16  
Old 11-18-2004
I'm using KSH
# 17  
Old 11-18-2004
Then try:
grep "$(date +"%b %d")" order.log|grep "SEVERE" > file1 ; [[ -s file1 ]] && uuencode file1 file1 | mailx X@Y.com
# 18  
Old 11-19-2004
Would it be possible to store a list of email addresses in another file and have this code loop through this list, sending the email to every recipient in this list?
# 19  
Old 11-19-2004
You can have more than one recipient with mailx. Just tack them on the end. Or create an alias and send the mail to the alias. Either is more efficient than looping.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. Shell Programming and Scripting

Help with Mailx

Hi , I have written below code to send email from unix. The code is getting executed fine but i am not receiving any e mail . I am not sure what is going wrong . Do we need to do any configration setting before using Mailx? Please help set -vx echo 'Sending Mail' mailx -s "SEPA_TEST"... (2 Replies)
Discussion started by: Chandru_Raj
2 Replies

3. 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

4. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

5. Solaris

Using Mailx

I am new to Unix and i want to know when using mailx can we change the sender's name from the default one. (3 Replies)
Discussion started by: blackeyed
3 Replies

6. HP-UX

mailx help

Hi, I have a shell script which has code like: cat /tmp/MAIL_PCSD | mailx -m -s " PEWA Order Acknowledgement" $M1 and M1 is nothing but this M1=`echo $x | awk ' {print $3}' ` If I pass absolute email address to $M1 it works fine. But, the thing is that it gets $M1 by reading some... (3 Replies)
Discussion started by: isingh786
3 Replies

7. UNIX for Advanced & Expert Users

MAILX help

Hello all, how do I view the default mail configurations using the mailx problem? At the moment, I have an account, and all the mail to that account is being routed to an email address, how can I view this behaviour? Also, is there anyway I can view the default mail settings for a server without... (0 Replies)
Discussion started by: Khoomfire
0 Replies

8. UNIX for Dummies Questions & Answers

mailx error message : mailx: NUL changed to @

If I use the "Mail" link instead of the "mail" link to ../mailx I get this error. Mail so-n-so @whatever.com mailx: NUL changed to @ Unknown command: "postmaster" The email still goes through but i get the error. If I use "mail" it goes thru without the error. Any ideas?? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

9. Shell Programming and Scripting

Mailx

I am trying to write a shell script using the mailx command. My problem is that I want to send an email address in the CC: field. What option can I use with mailx to accomplish this. Any help would be very appreciative. (1 Reply)
Discussion started by: skammer
1 Replies

10. UNIX for Dummies Questions & Answers

Need help with mailx

How can I send a file of Unix usernames to everyone on the file without making an alias in my .mailrc file? Using a mailx command. Thanks, J.J. (2 Replies)
Discussion started by: JJJ
2 Replies
Login or Register to Ask a Question