send an email of script output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting send an email of script output
# 1  
Old 07-24-2009
send an email of script output

Hi All,

I'm trying to send some file which generated by script to my email. when I run the script I'm getting an email. Thats fine. But it seems to be all messed up like below

Memory Status on ServerA: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!! CPU Status on ServerA: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st DEV POrt are OK on ServerA. Service is running. Memory Status on ServerB: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!! CPU Status on ServerA: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st DEV POrt are OK on ServerB. Service is running.on ServerB


I want to make it seperate lines like below

Memory Status on ServerA: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!!
CPU Status on ServerA: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st
DEV POrt are OK on ServerA.
Service is running on ServerA.


Memory Status on ServerB: Mem: 3867444k total, 862680k used, 3004764k free, 54456k buffers!!
CPU Status on ServerB: Cpu(s): 1.8%us, 2.3%sy, 0.1%ni, 94.1%id, 0.6%wa, 0.0%hi, 1.1%si, 0.0%st
DEV POrt are OK on ServerB.
Service is running on ServerB.

Is there anyway to do so in the script. Thanks.
# 2  
Old 07-24-2009
What is the code that is generating the inappropriate output?
# 3  
Old 07-24-2009
Hi.

This is most likely happening because windows expects a CRLF (carriage-return linefeed) (^M^J) character and UNIX has only the LF (^J) character.

You can easily convert the file using
Code:
unix2dos

before you send it.

Or you could send it via attachment using
Code:
uuencode myfile myfile.txt | mail......

and use something other than Notepad to open it.

(I did make one assumption: you are trying to read the file in Windows!)
# 4  
Old 07-25-2009
How is the script generating the output? If it is using echo, then you should use "echo -e" with \r at the end.

If you use it then you should not have CR problems when outputting data to an email (or to a text file).

(I am also assuming you are trying to email it and read on a Windows machine That's what I was doing when I found this answer... )

Last edited by ppucci; 07-25-2009 at 09:57 PM.. Reason: confused -n and -e... fixed
# 5  
Old 07-25-2009
Please post the script which generates the mail and state which Operating System you use and which shell. Also please state your Mail Reader and version.


Sometimes this problem is caused by an unwanted setting in Microsoft Office Outlook which should be unchecked:

Code:
Tools/Options/Preferences/E-mail options/Remove extra line breaks in plain text messages

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need little script to send out email

Hi Scripters, good day. bash-4.2# df -g /apps/prd Filesystem GB blocks Free %Used Iused %Iused Mounted on /dev/xxx 64.00 4.35 94% 1269284 8% /xxx bash-4.2# I was wondering if there is a script when the usage of the mountpoint above hit 98%, email would be... (3 Replies)
Discussion started by: jaapar
3 Replies

2. Solaris

How to output the prstat into table and send through email?

Hi how to send below prstat script output into table format and send through email? prstat|awk '{ if ($9 >= 5) print $0 }' (17 Replies)
Discussion started by: tharmendran
17 Replies

3. Shell Programming and Scripting

Parse qshape output and send email alert

Hi I need help to do this. This is the output of qshape: user$ qshape deferred|head T 5 10 20 40 80 160 320 640 1280 1280+ TOTAL 0 0 0 0 0 0 0 0 0 0 0 T stands for minutes elapsed and TOTAL... (1 Reply)
Discussion started by: zorrox
1 Replies

4. Shell Programming and Scripting

SQL query output convert to HTML & send as email body

Hi , I have a sql query in the unix script ,whose output is shown below.I want to convert this output to HTML table format & send email from unix with this table as email body. p_id src_system amount 1 A 100 2 B 200 3 C ... (3 Replies)
Discussion started by: jagadeeshn04
3 Replies

5. Shell Programming and Scripting

Send email if Output is available

hello can anyone debug these lines cd /usr/local/scripts ./build update ./build versions | grep available if then mail -s "update for server `hostname`" $EMAIL else echo -e "$YELLOW No update $RESET" fi echo "Please press a key - Back to main menu . . ." ; read but... (3 Replies)
Discussion started by: nimafire
3 Replies

6. Shell Programming and Scripting

Send output of a command as an email

Hello Unix Experts! We are on AIX 6.1 TL6 I am trying to develop a script that does the following: It should send the output of "df -g /directory/folder" command as an email to a user(someone@company.com) This is too simple and i can research on how to do it, but it would be great if... (2 Replies)
Discussion started by: atechcorp
2 Replies

7. Shell Programming and Scripting

how to avoid cron job output to send to the junk email folder?

Hi i created a cron job which invoke a shell script and output some content via email. Some times these output are sent to the junk email folder. i want these mails to be sent to inbox with some specific font. what i have to do? (4 Replies)
Discussion started by: vidhyaS
4 Replies

8. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

9. Shell Programming and Scripting

Send email on script error

I need to start off by saying that I am not much of a programmer and know enough to cause lots of trouble. I've been writing this script to decrypt an XML feed, then parse the feed into a database. The script is executed from cron. #!/bin/sh PGPPATH=/path/to/directory echo "pgp... (6 Replies)
Discussion started by: Aslan_Eident
6 Replies

10. Shell Programming and Scripting

Send one email with output result from 2 commands

Hi, i want to create a script which should do the following: 1) ping the remote servers and email the hosts which are down 2) netstat on port x on 2 server and email the result too. I want both results to be sent in the same email. I have few ideas but i can't finish it. Here... (4 Replies)
Discussion started by: varu0612
4 Replies
Login or Register to Ask a Question