Improve company productivity with a Business Account.Sign Up

x
?
Solved

Multiple line output from command line in SMTP

Posted on 2010-09-06
16
Medium Priority
?
438 Views
Last Modified: 2012-05-10
I am not sure how to word this.
i am using a command line SMTP client to send a log file as a email. the utility is bmail.
http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm

bmail -s localhost -t %%A -f backup@domain.local -h -a "Backup Report - %Date%" -b "Start time:%StartTime% End Time:%EndTime%" -m "%Logfile%"

The part:  -b "Start time:%StartTime% End Time:%EndTime%"
The output it is giving is Start time:16:27:18.77 End Time:16:28:03

I want it to be:
Start time:16:27:18.77
End Time:16:28:03

How do i get it to return to the next line between the 2 parts?
0
Comment
Question by:tsukraw
  • 7
  • 3
  • 3
  • +1
15 Comments
 
LVL 21

Assisted Solution

by:AmazingTech
AmazingTech earned 498 total points
ID: 33615393
I don't think you can with the -b parameter. Perhaps you can create a text file and then use the -d.

echo Start time:%StartTime%>Body.txt
echo End Time:%EndTime%>>Body.txt

bmail -s localhost -t %%A -f backup@domain.local -h -a "Backup Report - %Date%" -d Body.txt  -m "%Logfile%"
0
 

Author Comment

by:tsukraw
ID: 33615400
-d is debug?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33616383
I think he means -m,

Steve
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 501 total points
ID: 33616406
And I don't know what happened to the code segment I attached there, typing in directly this time... just creates a new file in temp with your log details then the original log file.

Steve

set log="%temp%\logfile.txt"
echo Start time:%StartTime%>%log%
echo End Time:%EndTime%>>%log%
echo. >> %log%
type %logile% >%log%
bmail -s localhost -t %%A -f backup@domain.local -h -a "Backup Report - %Date%" -d Body.txt  -m "%Log%"
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33616409
Sorry forgot to change the last time second time around:
set log="%temp%\logfile.txt"
echo Start time:%StartTime%>%log%
echo End Time:%EndTime%>>%log%
echo. >> %log%
type %logile% >%log%
bmail -s localhost -t %%A -f backup@domain.local -h -a "Backup Report - %Date%"  -m %Log%
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33616417
I blame EE not accepting it first time around .... try changing

type %logile% >%log%


to
type %logfile% >>%log%

too!

Steve
0
 
LVL 61

Expert Comment

by:Bill Prew
ID: 33616687
I believe the piece that Tucker may not have shared is that the log file he is already attaching is generated out of a utility program, so that file needs to be attached, and can not be pre-pended to.  In addition to having that file attached, he wants a multiline body.

It doesn't look like bmail accepts multiple -m files so not sure how to solve this?

~bp
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33616707
That is why I was (trying) to suggest creating the new text and then Appending the old file to the end and attaching that one instead.

Personally I tend to use blat.exe for mailing though have had to use bmail.exe for some people and can't think of another way at the moment short of using one of the MIME body encoding progs to make a body and attach it.

Steve
0
 
LVL 61

Expert Comment

by:Bill Prew
ID: 33616740
Gotcha Steve.

~bp
0
 

Author Comment

by:tsukraw
ID: 33616782
So overall the solution would be to have the script create a new log file with the content I want and join the utilities output log int it?  
outputting the content I want to a file is simple enough but how do I join the other file into it?
0
 
LVL 61

Accepted Solution

by:
Bill Prew earned 501 total points
ID: 33616905
Tucker,

I think the resultant script would look like this.

Notice that we capture the output of the backup to a temporary log file (log.txt) and then after writing the begin and end header lines to the real log file we add on the output of the backup command.  Then that is what we email.

Make sense?

~bp
@echo off
set Day=%DATE:~10,4%_%DATE:~4,2%_%DATE:~7,2%
set CurrentDir=%~dp0
if "%CurrentDir:~-1%"=="\" set CurrentDir=%CurrentDir:~0,-1%
set Logfile=%CurrentDir%\BackupLogs\G-Drive-%Day%.txt
 
echo Start Time:%TIME%>"%Logfile%"
 
wbadmin start backup -backupTarget:G: -include:F: -quiet > "%TEMP%\log.txt"
 
echo End Time:%TIME%>>"%Logfile%"
echo.>>"%Logfile%"
type "%TEMP%\log.txt" >>"%Logfile%"
 
for /F "usebackq tokens=*" %%A in ("emailaddy.txt") do (
  bmail -s localhost -t %%A -f backup@severname -h -a "Backup Report - %Date%" -m "%Logfile%"
)

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33617154
Didn't know this was a follow up Bill.  

See post 33616409 / 33616417 above :-)

Steve
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 33629303
Sorry, I was replying on my iPhone so the -d should have been the -m but also include the log file like how dragon-it explained it.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 34080713
Accept billprew http:#33616905.
Assist dragon-it http:#33616409
and AmazingTech http:#33615393
0
 

Author Closing Comment

by:tsukraw
ID: 34089452
Really no solution with this app.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
In the video, one can understand the process of resizing images in single or bulk. Kernel Bulk Image Resizer is an easy to use tool for resizing large number of images. One can add and resize multiple images with this tool in single go. The video sh…
Watch the software video of Kernel Import PST to Office 365 tools which can easily import PST and OST files to Office 365 for bulk mailboxes. The process of migration is simple and user can map source and destination mailboxes and easily import data…

595 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question