Mailx usage


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mailx usage
# 1  
Old 04-28-2008
Mailx usage

Hi
Having the below four log files.

logfile1
Code:
date               time        server     ip 
10/10/2008      10:10      ServerA   xxx.xxx.xxx.xxx
10/10/2008      10:11      ServerA   xxx.xxx.xxx.xxx
10/10/2008      10:12      ServerA   xxx.xxx.xxx.xxx

logfile2
Code:
date               time        server     ip 
10/10/2008      10:10      ServerB   xxx.xxx.xxx.xxx
10/10/2008      10:10      ServerB   xxx.xxx.xxx.xxx
10/10/2008      10:10      ServerB   xxx.xxx.xxx.xxx

ans so on...

how to send mail using mailx
i need to sent all the four files in one email
i tried this... any one can suggest

Code:
cat logfile1 >> logfile
cat logfile2 >> logfile
cat logfile3 >> logfile
cat logfile4 >> logfile

cat logfile | mailx -s 'Server logs for the day' xxx@xxx.com

i am not able to insert any headers after each log files
but i need like the below format

Body of email
==========
Code:
Server A Logs for the day 
===================
XXX
XXX
XXX

Server B Logs for the day 
===================
XXX
XXX
XXX

Server C Logs for the day 
===================
XXX
XXX
XXX

Server D Logs for the day 
===================
XXX
XXX
XXX

can any one help me how to manipulate this

Thanks in advance
# 2  
Old 04-28-2008
Hi,
You could insert the 'headers' between each cat
Code:
echo "Server A Logs for the day" >> logfile
echo "=========================" >> logfile
cat logfile1 >> logfile
echo "Server B Logs for the day" >> logfile
echo "=========================" >> logfile
cat logfile2 >> logfile
...
cat logfile3 >> logfile

cat logfile | mailx -s 'Server logs for the day' xxx@xxx.com

# 3  
Old 04-28-2008
Or create them as attachments; the mail FAQ section has a script you can use.

PS. That was quite an orgy of useless cats. The purpose of cat is to catenate files. Even though it doesn't work, I need to point out that the Useful way to write your original command would have been

Code:
cat logfile1 logfile2 logfile3 logfile4 | mailx -s 'Server logs for the day' xxx@xxx.com

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Memory usage per user,percent usage,sytem time in ksh

Let's say i have 20 users logged on Server. How can I know how much memory percent used each of them is using with system time in each user? (2 Replies)
Discussion started by: roy1912
2 Replies

2. HP-UX

mailx usage doubt

How to use mailx to send a mail by specifying the from: address, considering that i am the root user (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

3. UNIX for Dummies Questions & Answers

Command to display the space usage (memory usage) of a specific directory.

Hi all, Can you please tell me the command, with which one can know the amount of space a specific directory has used. df -k . ---> Displays, the amount of space allocated, and used for a directory. du -k <dir name> - gives me the memory used of all the files inside <dir> But i... (2 Replies)
Discussion started by: abhisheksunkari
2 Replies

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

5. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

6. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

7. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

8. Programming

CPU usage and memory usage

Please tell me solaris functions/api for getting following information 1- Function that tells how much memory used by current process 2- Function that tells how much memory used by all running processes 3- Function that tells how much CPU is used by current process 4- Function that tells how... (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

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

10. Programming

Monitor CPU usage and Memory Usage

how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries through a c program or java program i want to store that data into database so i can show it graphically thanks in advance (2 Replies)
Discussion started by: Gajanad Bihani
2 Replies
Login or Register to Ask a Question