how to send last file with mailx


 
Thread Tools Search this Thread
Operating Systems Solaris how to send last file with mailx
# 1  
Old 06-16-2010
how to send last file with mailx

I use mailx to send some log files. The log files are generated hourly. So many files stored in that folder.

The log file is saved to a directory as "FILE_NAME=$ORACLE_SID`date + %m%d%y_%T`.

I use syntax like this:

mailx -s 'subject' myemail@company.com < /directory/$FILE_NAME

Because many files stored in that folder, but I only want to send the latest file with mailx command. Is my current code work? Please advise and give me some comments. Thanks.
This User Gave Thanks to duke0001 For This Post:
# 2  
Old 06-16-2010
If you're running mailx from the same script that you are generating the logfile in, then your syntax will work, as long as $FILENAME is set before you run the mailx command.

That would be the proper way to do it.

If you're running mailx separately, you'll have to figure out a way to find the last file, and not just keep sending the same file over and over, depending on how often the files are generated, and how often the mailx command is run.
# 3  
Old 06-16-2010
malcolmpdx:

Thanks so much for your response. I haven't received any log file yet.

I have another question. Because I used cron job to trigger the shell script to generate the log files. In the end of cron job, I used to > /dev/null 2>&1 to disable cron job to send email. If I don't take this code off, will the mailx command in shell script continue to send log file to my email box?

Last edited by duke0001; 06-16-2010 at 05:25 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mailx command to send attachment file

Hi, I need to send a attachment which has space in the file name as: "ABC Data Extract.txt" which is present in the location /home/projects/txt i am using /home/projects/scripts mailx -s "Sub" email_id "/home/projects/txt/ABC Data Extract.txt" but i am not getting the attachment. (7 Replies)
Discussion started by: ATWC
7 Replies

2. Shell Programming and Scripting

want to send .csv file as an attachment using mailx command.

want to send .csv file as an attachment using mailx command. Please help!!! (1 Reply)
Discussion started by: gagandeep
1 Replies

3. Shell Programming and Scripting

Send mail using mailx to CC only, not TO

Hi All, I am using mailx to send the mail. Due to some changes in the requirement, I need to send the mail to CC only (an Email id in CC), with no email ID in "TO" field. Can we do that? bcz I used -c flag only and got the message:":The flags you gave make no sense since you're not sending... (2 Replies)
Discussion started by: unankix
2 Replies

4. Linux

mailx: Unable to send Japanese

Hi All, I am facing problem in sending Japanese characters using mailx command in GNU linux machine. The mail is going with junk characters like "メールの-界へようこそ". I tried changing the LANG value to japan locale off UTF-8. But it doesn't worked. I have to send the data as body not as an... (0 Replies)
Discussion started by: Karteek
0 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. Solaris

How can i use Mailx to send email

I would like to use Mailx command, please i hope when you replay give me example. because this is very good think for me. I am New in sun Microsystems Solaris 10, i hope to give me also rules to learn Solaris easily. Thank you Joseph Shafik (8 Replies)
Discussion started by: J.shafik
8 Replies

7. UNIX for Advanced & Expert Users

how to send file as attachment using mail or mailx

I have a need to send a file from the unix command line to be sent as an attachment. Is this possible? That is when I open my outlook email I need to file to appear as an attachment. Also, is there a way to use the mail binary (not mailx) to modify the "reply address". mailx -r works but I need... (1 Reply)
Discussion started by: kieranfoley
1 Replies

8. Debian

cannot send any mails using mailx

hi howto configure mailx ? kind regards ccc (11 Replies)
Discussion started by: ccc
11 Replies

9. Shell Programming and Scripting

HELP!!! how to send PDF file as an attachment using mailx

Hi, iam using the following command: uuencode file1.pdf file1.pdf|mailx - s "waz up?" xyz@domain.com Iam recieving an encoding error when i try to open the attachment. Pls help..very urgent!!! (1 Reply)
Discussion started by: Brat
1 Replies

10. UNIX for Dummies Questions & Answers

using mailx to send a log file to my outlook e-mail account

I like to use mailx -s to send an entire xxxxx.log to my outlook e-mail account. Any help will be appreciated. Thanks. (6 Replies)
Discussion started by: simt
6 Replies
Login or Register to Ask a Question