[Solved] Cant get message body


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Cant get message body
# 1  
Old 02-21-2013
Reference [Solved] Cant get message body

Hi guys . I am trying to take the output of top command and mail it to myself . The code is :

Code:
echo ##############################################################

/usr/local/bin/top c n 1 b >> /export/home/top-output.txt
echo ##############################################################


WT_TO=`tail -22 /export/home/top-output.txt`


cat $WT_TO | mailx -s "Top Command OutPut" myemail@address.com

The body is empty ! Whereas if i open the txt file , I do get an output.
# 2  
Old 02-21-2013
Hi,
there is a little mistake. Try:

Code:
echo $WT_TO | mailx -s "Top Command OutPut" myemail@address.com

# 3  
Old 02-21-2013
Code:
echo "$WT_TO" | mailx -s "Top Command OutPut" myemail@address.com

Or in one stroke:
Code:
tail -22 /export/home/top-output.txt |
mailx -s "Top Command OutPut" myemail@address.com

# 4  
Old 02-21-2013
Thankyou . It does work but it sends data in this form :
Code:
load averages: 14.5, 15.4, 15.9; up 3+20:00:34 22:41:00 1238 processes: 1212 sleeping, 1 running, 1 zombie, 24 on cpu CPU states: 56.0% idle, 13.2% user, 30.8% kernel, 0.0% iowait, 0.0% swap Memory: 96G phys mem, 8761M free mem, 96G total swap, 95G free swap PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND 464 root 72 49 0 24M 16M cpu/65 865:42 2.59% nscd 16862 dbm 1 0 2 1752K 1272K sleep 0:01 2.02% mv 27068 oracle 1 32 0 4250M 4233M cpu/64 403:25 1.96% oracle 142 oracle 258 46 0 45G 3326M sleep 143:41 1.05% oracle 140 oracle 258 54 0 45G 3327M sleep 148:54 0.91% oracle 29014 oracle 11 0 0 45G 27G sleep 65:18 0.76% oracle 10837 oracle 11 37 0 45G 27G sleep 0:08 0.74% oracle 4439 oracle 11 2 0 10G 10G sleep 40:35 0.55% oracle 16961 tcs 1 0 2 1928K 1616K sleep 0:00 0.51% ps 16951 tcs 1 0 2 1928K 1616K cpu/48 0:00 0.51% ps 16947 tesb 1 0 2 1928K 1616K sleep 0:00 0.51% ps 16960 tcs 1 0 2 1928K 1616K sleep 0:00 0.50% ps 17083 tesb 1 0 2 1928K 1616K cpu/74 0:00 0.48% ps 1!
 5694 tcs 11 60 2 45G 27G sleep 20:13 0.43% oracle 17037 tcs 1 0 2 1928K 1616K sleep 0:00 0.43% ps

Whereas it should be in the form :

Code:
load averages:  19.0,  19.4,  19.9;                    up 3+18:54:16   21:34:42
1084 processes: 1074 sleeping, 1 running, 1 zombie, 8 on cpu
CPU states: 74.1% idle, 13.9% user, 11.9% kernel,  0.0% iowait,  0.0% swap
Memory: 96G phys mem, 8168M free mem, 96G total swap, 95G free swap

   PID USERNAME LWP PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND
 12383 dbm        1   0    2 2000K 1456K cpu/9    0:02  1.95% gzip
 29014 oracle    11   2    0   45G   27G cpu/0   33:54  1.40% oracle
  4439 oracle    11  59    0   10G   10G cpu/3    4:56  1.21% oracle
 12503 dbm        1  60    2 2000K 1456K sleep    0:00  0.91% gzip
    90 oracle     1  20    0   45G 2390M run    767:35  0.78% oracle
 14178 oracle    11  60    0   45G   27G sleep    0:12  0.63% oracle
 12687 oracle    11  39    0   45G   27G sleep    0:11  0.46% oracle
 27239 root      11 100  -20  230M  201M sleep  596:23  0.41% osysmond.bin
  1004 tesb      54  53    2 3908M 1303M sleep   43:11  0.36% java
  8066 oracle     1   5    0   45G   27G sleep    0:05  0.35% oracle
 15694 tcs       11  60    2   45G   27G sleep    8:57  0.33% oracle
  7477 oracle    35  60    0   45G   27G sleep    1:21  0.33% oracle
  2234 oracle     1  30    0   10G   10G sleep  581:10  0.30% oracle
  2268 oracle   258  32    0   10G   10G sleep  177:43  0.30% oracle
  1727 tcs       43  53    2  354M  278M sleep   47:07  0.29% java

# 5  
Old 02-21-2013
Run as suggested by MadeInGermany:
Code:
tail -22 /export/home/top-output.txt | mailx -s "Top Command OutPut" yemail@address.com

# 6  
Old 02-21-2013
Using MadeInGermany's code:
Code:
tail -22 /export/home/top-output.txt | \unix2dos |
mailx -s "Top Command OutPut" myemail@address.com

use ux2dos or unix2dos depending of your OS...
# 7  
Old 02-21-2013
Works like a charm. Thankyou all !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Sending email with message body and attachment

Hello experts!! I am trying to send an email with message body and attachment.but i am getting any one like message body or attachment. I tried below command: (echo "subject:test";echo "MIME-Version: 1.0";echo "content-transfer-encoding:base 64";echo "content-type:txt;name=test.txt";cat... (2 Replies)
Discussion started by: Devipriya Ch
2 Replies

2. Shell Programming and Scripting

Message Body while sending an email

I am making use of the following code to display the results of my txt file in an email: mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com < Count_Validation_Results_`date +%m%d%Y`.txt Email Output: ----------Query 1 Count Validation Results-------- Source count is 4 Target... (7 Replies)
Discussion started by: ronitreddy
7 Replies

3. Shell Programming and Scripting

Mailx with attachment and message body

i have to attach the 'body in the email' along with attachment below code is throwing errors, how can i do it ? here body file contains message, it should display in email, please help i am using HP-UX (cat body ;) (uuencode attch1 attch1 ;) | mailx -m -s "testing" "abc@gmail.com" ... (4 Replies)
Discussion started by: only4satish
4 Replies

4. UNIX for Dummies Questions & Answers

Mailx empty body message

Hi, Is there a way to suppress this message? Null message body; hope that's ok My email string is: mailx -s "This is my subject" myemail@domain.com < /dev/null It's just an annoyance to me that I would like see go away. (3 Replies)
Discussion started by: bbbngowc
3 Replies

5. Shell Programming and Scripting

How to send a mail with attachement as well as message Body..?

Hi all, i am working with CSH, i want to know that how to send a mail in UNIX shell script (CSH) with attachment as well as message body. i know that how to send a mail with attachment and message body. but i want know both things in a single mail Suggession would be appreciate. ... (1 Reply)
Discussion started by: psiva_arul
1 Replies

6. Shell Programming and Scripting

perl/mail - inserting file text in message body

I've got the following code sub mail_report { $Mailer = '/usr/sbin/sendmail joe@somewhere.net'; open MAIL,"|$Mailer"; print MAIL "Subject: $X connection attempt \n"; open MESSAGE, "<$outdir$X"; print MESSAGE '$outdir$X\n'; close MESSAGE; close MAIL; } #End... (2 Replies)
Discussion started by: thumper
2 Replies

7. Shell Programming and Scripting

mailx: concatenating strings for message body (KSH)

Hi all, Think this is a pretty simple problem, but I've been thinking about it for a few days. Let's say that I'm going to have to output the contents of a file as the body of a mailx message. I'll probably do this: cat <filename> | mailx <extra commands> However, how do I go about doing... (1 Reply)
Discussion started by: rockysfr
1 Replies

8. UNIX for Dummies Questions & Answers

AIX send mail with HTML message body and a binary attachment

I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command line switch to specify file name of a binary attachment 3. command line or input file to specify... (4 Replies)
Discussion started by: G-Man
4 Replies

9. UNIX for Dummies Questions & Answers

How to get åäö in e-mail message body

First of all: Hi all, i´m a new unix user and i´m swedish so please bare with me. When i generate an e-mail on a unix server and send it through novell netware 5, i loose the swedish characters å, ä and ö in the body of the message, however they remain in the subject row. What to do? Anyone?... (4 Replies)
Discussion started by: de98luto
4 Replies

10. UNIX for Dummies Questions & Answers

sendmail message body buffer limit?

when sending the contents of a ascii file to the body of an email then sending it off. it seems sendmail is breaking up the lines with a "!" thus ruining the data. Has this ever happened to anyone? i am guessing there is a line buffer limit in either the mail command or in sendmail itself. ... (3 Replies)
Discussion started by: Optimus_P
3 Replies
Login or Register to Ask a Question