The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mailx Paul Byrne UNIX for Advanced & Expert Users 6 06-23-2008 04:28 AM
MailX rajani_p UNIX and Linux Applications 0 10-23-2007 12:14 AM
CPU usage and memory usage mansoorulhaq High Level Programming 1 08-09-2007 04:55 PM
mailx error message : mailx: NUL changed to @ BG_JrAdmin UNIX for Dummies Questions & Answers 2 12-01-2005 10:27 AM
Monitor CPU usage and Memory Usage Gajanad Bihani High Level Programming 2 03-09-2005 07:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-28-2008
karthikn7974's Avatar
karthikn7974 karthikn7974 is offline VIP Member  
Supporter
  
 

Join Date: Jul 2007
Location: Singapore
Posts: 58
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 (permalink)  
Old 04-28-2008
andryk's Avatar
andryk andryk is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2003
Posts: 448
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 (permalink)  
Old 04-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0