help with grep and mailx


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help with grep and mailx
# 8  
Old 11-16-2004
I worked out the script Perderabo !!

Please let me know what's wrong with that ;

The theread starter wants the solution in single line that drove me to experiment like that ;

Please let me know if any thing wrong with that ;

I agree there may be simple solution for this .
# 9  
Old 11-16-2004
I got yourr point .... ;

a=`date | cut -d" " -f 2,3`
grep "$a" testfile | grep "SEVERE" | tee file1 | uuencode file1 file1 | mailx X@Y.com


Might be good
# 10  
Old 11-16-2004
You can feed date a parameter to make to output the date in various formats.

date | cut -d" " -f 2,3
date "+%b %d"

both produce the same result. I don't understand why you introduced that variable a. It seems to serve no purpose.

Try:
grep "$(date "%b %d")" testfile | grep "SEVERE" | tee file1 | uuencode file1 file1 | mailx X@Y.com
# 11  
Old 11-17-2004
Thanks for all your replies. This has been a learning experience for me and I appreciate your help.

I have 2 minor changes...

The date it needs to look for has a space between the month and the day (Nov 17). Also, is there a way to have it not send the email if there are no severe errors? I know this probably can't be done in a single line, and that is OK.

Thanks again!
# 12  
Old 11-18-2004
Help... I ran this line and I do get an email with an attachment, but the attached file is empty.

grep "$(date +"%b %d")" order.log|grep "SEVERE"|tee ord_err.log|uuencode ord_err.log ord_err.log|mailx -s "test"
xyz@xyz.com

I ran just this part of it: grep "$(date +"%b %d")" order.log|grep "SEVERE" and I do get output as seen below:

Nov 18 05:02:26 [SEVERE] Ord <R00055430405-SFI> has status <S> and therefore can't be deleted.
Nov 18 08:47:17 [SEVERE] Ord <P00000553218-SFI> has status <S> and therefore can't be deleted.
Nov 18 08:47:17 [SEVERE] Ord <P00000554462-SFI> has status <S> and therefore can't be deleted.
Nov 18 08:47:17 [SEVERE] Ord <P00000553781-SFI> has status <S> and therefore can't be deleted.
Nov 18 08:47:17 [SEVERE] Ord <P00000552862-SFI> has status <S> and therefore can't be deleted.
Nov 18 08:47:17 [SEVERE] Ord <P00000553084-SFI> has status <S> and therefore can't be deleted.
Nov 18 08:47:17 [SEVERE] Ord <P00000553640-SFI> has status <S> and therefore can't be deleted.
Nov 18 08:47:17 [SEVERE] Ord <P00000550070-SFI> has status <S> and therefore can't be deleted.
Nov 18 08:47:17 [SEVERE] Ord <P00000553780-SFI> has status <S> and therefore can't be deleted.

Question is, why is it sending a blank file?
# 13  
Old 11-18-2004
I do n't see any prblem with that ;
It is perfectly working for me ;

Do one thing ... ;

Check file1 which is created in yr directory. Check/See its size.

Also

Test uuencode with some dummy text file to check whether second part is working or not ;


Or try ... sendmail ....
# 14  
Old 11-18-2004
The file size of order.log is 0, even though there are records in it that file that are both SEVERE and have a date of Nov 18.

After I get this to work, is there a way to code it so that it does the grep and if there are no errors, simply exits?

Steve
 
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