Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Multiple line output from command line in SMTP

Posted on 2010-09-06
16
421 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
16 Comments
 
LVL 21

Assisted Solution

by:AmazingTech
AmazingTech earned 166 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 167 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 53

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 53

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 53

Accepted Solution

by:
Bill Prew earned 167 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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