Issue with emailing format from UNIX

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Issue with emailing format from UNIX
# 1  
Old 09-22-2016
Wrench Issue with emailing format from UNIX

Need help as to why when I try email the following it does not come out right:


Code:
DateOt=`date +"%a %b %d %T %Y"`
TimeOt=`date +%H:%M:%S`
interval=`cat $SecDiff| awk '{print $3}'`
PortInReq2=`cat /shared/ftpdir/tools/quelog/logs/quelog.NPS_TO_SMG.log | grep PQI | wc -l`
PortInRes2=`cat /shared/ftpdir/tools/quelog/logs/quelog.SMG_TO_NPS.log | grep PRI | wc -l`
PortOtReq2=`cat /shared/ftpdir/tools/quelog/logs/quelog.SMG_TO_NPS.log | grep PQ2 | wc -l`
PortOtRes2=`cat /shared/ftpdir/tools/quelog/logs/quelog.NPS_TO_SMG.log | grep PR2 | wc -l`
echo "$DateOt " >> $Rptfile
echo "@$TimeOt==> PortIn Requests count = $PortInReq2 " >> $Rptfile
echo "@$TimeOt==> PortIn Response count = $PortInRes2 " >> $Rptfile
echo "@$TimeOt==> PortOut Requests count= $PortOtReq2 " >> $Rptfile
echo "@$TimeOt==> PortOut Respense count= $PortOtRes2 " >> $Rptfile
$scriptpath/sendmail.ksh "SMG PortIn/Out counts Report." $alarmtos $Rptfile

The report file looks fine:

Quote:
@19:00:00==> PortIn Requests count = 13399
@19:00:00==> PortIn Response count = 12945
@19:00:00==> PortOut Requests count= 16022
@19:00:00==> PortOut Respense count= 16744
when emailed it is all in one line !!! as follows:

Quote:
Thu Sep 22 18:59:05 2016
@18:59:05==> PortIn Requests count = 13369 @18:59:05==> PortIn Response count = 12917 @18:59:05==> PortOut Requests count= 16007 @18:59:05==> PortOut Response count= 16726
# 2  
Old 09-22-2016
How are you reading the report after it is received via email? If you are reading it in Windows then you can try and use NotePad (instead of WordPad). You can also run a unix2dos command on the file (before it gets emailed) which will "prepare" the file for Windows users.
# 3  
Old 09-23-2016
Before we look at the issue, could I suggest you convert this:-
Code:
PortInReq2=`cat /shared/ftpdir/tools/quelog/logs/quelog.NPS_TO_SMG.log | grep PQI | wc -l`

.... to this:-
Code:
PortInReq2=$(grep -c PQI /shared/ftpdir/tools/quelog/logs/quelog.NPS_TO_SMG.log)

It is far neater and saves a few processes, which can be important if you are running this in the loop.

Additionally this:-
Code:
interval=`cat $SecDiff| awk '{print $3}'`

....becomes:-
Code:
interval=$(awk '{print $3}' $SecDiff)

...or perhaps:-
Code:
interval=$(cut -f3 -d " " $SecDiff)

.... although all ways (including yours) assume that you only have a single record in the file referenced by $SecDiff.

It might also be cleaner to do the displays as a single IO write so this:-
Code:
echo "$DateOt " >> $Rptfile
echo "@$TimeOt==> PortIn Requests count = $PortInReq2 " >> $Rptfile
echo "@$TimeOt==> PortIn Response count = $PortInRes2 " >> $Rptfile
echo "@$TimeOt==> PortOut Requests count= $PortOtReq2 " >> $Rptfile
echo "@$TimeOt==> PortOut Respense count= $PortOtRes2 " >> $Rptfile

....becomes:-
Code:
{
echo "$DateOt "
echo "@$TimeOt==> PortIn Requests count = $PortInReq2 "
echo "@$TimeOt==> PortIn Response count = $PortInRes2 "
echo "@$TimeOt==> PortOut Requests count= $PortOtReq2 "
echo "@$TimeOt==> PortOut Respense count= $PortOtRes2 "
} >> $Rptfile




Now to your question, it partly depends on what you are sending to and how you are sending it. Can you show us the command you use? It is important to know if this is in-line text or an attachment. The flavour and version of whatever you refer to a Unix is important too as some tools can behave differently in the variations.


Kind regards,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Emailing results of a pl sql procedure from UNIX shell script

Hello All, I am writing the below unix script to email the result of a small pl sql procedure: #!/bin/bash ORACLE_HOME=/opt/oracle/orcts/product/9.2.0; export ORACLE_HOME SQLPLUS=$ORACLE_HOME/bin/sqlplus sqlplus -s user/pass@Db_instance<<EOF set echo off set feedback off set pages 0... (9 Replies)
Discussion started by: Bunty bedi
9 Replies

2. Shell Programming and Scripting

File read format issue in UNIX

hi all. my loop is getting failed eventhoug it is 1=1 but it is failure message. any help plz Output expected : echo "sucesss" code out=`cat bit.txt` if ]; then echo "sucess" else echo "Failure" (2 Replies)
Discussion started by: arun888
2 Replies

3. Shell Programming and Scripting

UNIX mail Format issue : Outlook 2007 and 2013

Hi, I prepare one backup report which drop mail with backup report. Same report looks different in outlook 2013. e.g : In outlook 2013 ( its a dummy example only ) : Server Instance Database Backup Time Status ------------------- --------- --------- -------------- ----------------------... (5 Replies)
Discussion started by: niteshtheone
5 Replies

4. UNIX for Dummies Questions & Answers

Shell script emailing issue

Hi, Im writing a shell script: #!/bin/bash #Send process which has exceeded 25% # echo 'pri pid user nice pcpu command' > /export/home/tjmoore/file2 # if ps -eo pri,pid,user,nice,pcpu,comm | awk '{if($5 >= 25)print $0}' >> /export/home/tjmoore/file2 2>/dev/null # # # then... (1 Reply)
Discussion started by: jay02
1 Replies

5. Shell Programming and Scripting

Converting windows format file to unix format using script

Hi, I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix. My requirement here is that i want to do it automatically using a... (5 Replies)
Discussion started by: sarbjit
5 Replies

6. Shell Programming and Scripting

Retaining the Unix CSV format in Excel format while exporting

Hi All, I have created a Unix Shell script whch creates a *.csv file and export it to Excel. The problem i am facing is that Users wants one of the AMOUNT field in comma separted values. Example : if the Amount has the value as 3000000 User wants to be in 3,000,000 format. This Amount format... (2 Replies)
Discussion started by: rawat_me01
2 Replies

7. Shell Programming and Scripting

Convert UNIX file format to PC format

Hi All, Is there any way to convert a file which is in UNIX format to a PC format.... Flip command can be used , apart form this command can we have any other way.... like usinf "awk" etc ..... main purpose of not using flip is that my Kshell doesnot support this comamnd.... (2 Replies)
Discussion started by: Samtel
2 Replies

8. UNIX for Dummies Questions & Answers

Convert UNIX file format to PC format

Hi All, Is there any way to convert a file which is in UNIX format to a PC format.... Flip command can be used , apart form this command can we have any other way.... like usinf "awk" etc ..... main purpose of not using flip is that my Kshell doesnot support this comamnd.... (1 Reply)
Discussion started by: Samtel
1 Replies

9. UNIX for Dummies Questions & Answers

SMTP - emailing issue

We are running an application engine program that sends email to a list of users. In our Test Env, users are able to receive the emails but in our Prod environment, they do not. We are running the same program, and using the same stmp config. any idea on how to troubleshoot? (3 Replies)
Discussion started by: tads98
3 Replies

10. UNIX for Dummies Questions & Answers

Question related to Emailing from UNIX

Hi All, I would like to write a script which sends an email to clients. mailx -s "TEST" $EMAIL_RECIPIENTS < FILE ...will send an email to EMAIL_RECIPIENTS with TEST as the subject and FILE as the body. Now I have a another CONTROL_FILE which is constant all the times (FILE in the above... (1 Reply)
Discussion started by: jingi1234
1 Replies
Login or Register to Ask a Question