Visit Our UNIX and Linux User Community


Getting email output in single line with out space in email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting email output in single line with out space in email
# 1  
Old 08-03-2016
Getting email output in single line with out space in email

I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping

my code
Code:
(
 echo "From: $FROM"
 echo "To: $MAILTO"
 echo "CC: $CC"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo
 echo
 echo $MESSAGE_0
 echo
 echo $DATE
 echo
 echo
 echo
 echo $MESSAGE_1
 echo
 cat $ATTACH3
 echo
 echo $MESSAGE_3
 echo
 cat $ATTACH2
 echo
) | /usr/sbin/sendmail $MAILTO $CC

output i am getting is :
Code:
  data collection done START TIME AND DATE : Wed Aug 3 13:15:06 GST 2016 No Issue Found while doing testing for data collection done on below URLs and ports

ideally i want to break each of them in different line with space



Moderator's Comments:
Mod Comment You've repeatedly been told NOT to use ICODE tags for your code and data sections. DON'T rely on the moderators to correct your posts.
PLEASE use code tags as required by forum rules!


---------- Post updated at 04:36 PM ---------- Previous update was at 02:51 PM ----------

Quote:
Originally Posted by mirwasim
I have tried below email method and i am getting every thing in single line . i have put echo to provide space, but it is not helping

my code
Code:
(
 echo "From: $FROM"
 echo "To: $MAILTO"
 echo "CC: $CC"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo
 echo
 echo $MESSAGE_0
 echo
 echo $DATE
 echo
 echo
 echo
 echo $MESSAGE_1
 echo
 cat $ATTACH3
 echo
 echo $MESSAGE_3
 echo
 cat $ATTACH2
 echo
) | /usr/sbin/sendmail $MAILTO $CC

output i am getting is :
Code:
  data collection done START TIME AND DATE : Wed Aug 3 13:15:06 GST 2016 No Issue Found while doing testing for data collection done on below URLs and ports

ideally i want to break each of them in different line with space



Moderator's Comments:
Mod Comment You've repeatedly been told NOT to use ICODE tags for your code and data sections. DON'T rely on the moderators to correct your posts.
PLEASE use code tags as required by forum rules!

thanks.
will do that

---------- Post updated at 05:04 PM ---------- Previous update was at 04:36 PM ----------

sure i will take care

Last edited by RudiC; 08-03-2016 at 08:04 AM.. Reason: CHanged ICODE to CODE tags.
# 2  
Old 08-03-2016
What do you mean by "output I am getting"? There shouldn't be any output but a mail being sent. Are there any log files?

If that's just one single line occurring, chances are that all those echoed messages and variables are overwriting each other because of <CR> characters in the stream. What OS/shell/editor are you using? Please post the output of od -ctx1 <your_output_line>...
# 3  
Old 08-03-2016
I am using
Code:
SunOS

and you gave me a command to run but what is that
Code:
<your_output_line>

i need to pass
# 4  
Old 08-03-2016
The line that you posted after "output i am getting is : ", whereever you got that from. And, please explain where you got it from.

Ohhh - by the way, what be the receiving mail client? Perhaps the problem lies on its side?
# 5  
Old 08-03-2016
This assumes you are complaining about how the final email looks on the user's screen.
You are ultimately writing an html document, not plain text.
Code:
echo "Content-Type: text/html"

One way to deal with your problem is to switch from html to text. Another is to use html scripting.

You may want to learn very basic html scripting, one site is here:

HTML br tag

This particular page deals with an html tag <br>. I cannot tell if you want line breaks
or not but place this tag at the end of each line of text you want displayed in email - each tag makes a line break.

It is up to you to find and use the various tags you require to get a correct format in the email.

Going text only is simpler from the programming point of view. Using /usr/bin/mailx instead of sendmail is also an easier approach.
# 6  
Old 08-03-2016
that is my message i have defined

you can see I am passing
Code:
$MESSAGE_0

Code:
$DATE

Code:
$MESSAGE_1

inside to send email

the out put is a defined message, but i am not able to break the line
# 7  
Old 08-03-2016
Next problem:
Consider enclosing "$MESSAGE_0" in double quotes in your echo statement. Do this for most of your echo statements as well.

Why? What happens if one of the words in the message is a UNIX command or a comment -- # character or > character?

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending sql output to email body with conditional subject line

hi , i have written below piece of code to meet the requirement but i am stuck in the logic here. the requirement are: 1) to send the sql out put to email body with proper formatting. 2) if count_matching = Yes then mail should triggered with the subject line ... (10 Replies)
Discussion started by: itzkashi
10 Replies

2. Shell Programming and Scripting

Generate disk space usage email alert

hi all members I have a shell script to generate disk space usage email alert if threshold is more than 80 %, now the requirement changed to keep sending alert emails for every 5% incremental usage ........ Any help would be greatly appreciated. ex - 80% , 85% ,90%,95%,100% we should get an... (6 Replies)
Discussion started by: anil529
6 Replies

3. Shell Programming and Scripting

Send Disk Space Usage Status via email

Hi Guys, Is there any way I can write a script that sends DISK SPACE USAGE STATUS via email once a week? Thanks, (5 Replies)
Discussion started by: g4v1n
5 Replies

4. Shell Programming and Scripting

Sending an email if system disk space is low

Hello i have a working script that sends me an email if system disk space is above 98%. I would like to add an extra command to the if condition. If disk space is above 98% it would also add an output of cd /var/log && du -sBM * |sort -n 2>&1 |grep -v -e "0M" -e "1M" command to the email. I'm... (2 Replies)
Discussion started by: taf130
2 Replies

5. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

6. Shell Programming and Scripting

Check and compare disk space and email it

I am very new to Linux and learning to script. This is for one of my servers at work that I have to keep track off as far as disk space and how it is used. I have tried to go line by line but little things keep chewing me up. I would appreciate any and all help or advice, and Mutt is installed on... (3 Replies)
Discussion started by: sgtjkj
3 Replies

7. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

8. Shell Programming and Scripting

Stripping out more than a space from a line, but keep single space.

Hi all, Is there a way to perform the above, I am trying to strip out more than one space from a line, but keep the single space. See below output example. My Name is test test2 test3 test4 test5 My Name is test test2 test3 test4 test5 Please note that the lines would contain... (7 Replies)
Discussion started by: eo29
7 Replies

9. Shell Programming and Scripting

Coverting Firstname <Space> Lastname into email id

I have a file like below : bash-2.03$ cat neweamil2 Nigueel Rafferty Thomas333 Middletonsss Shwaita33 Ambasss Zhi21 Caiss Saluweh Husain Nigueel Rafferty Saleuikh Husainse Desiyshskan Santhio Need to convert firstname <space> lastname into email id . For eg. (1st... (4 Replies)
Discussion started by: sriram003
4 Replies

10. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies

Featured Tech Videos