Solved

Sending last line of txt document using blat

Posted on 2008-06-18
8
402 Views
Last Modified: 2012-05-05
I am trying to send the last line of last_line.txt using Blat. What I have right now sends me the whole txt document in the body. I dont want all that because there our multiple lines. I just want the last line of last_line.txt. Here is what I have in my test.cmd file:

blat.exe "last_line.txt" -subject "A Screen Saver has been Changed" -to 123@mail.com -i ScreenSaver -priority 1 -server smtp.mydomain.com -f wpdomain


Any help is much appreciated. Thanks!
0
Comment
Question by:missywpitt
  • 4
  • 4
8 Comments
 
LVL 38

Expert Comment

by:Shift-3
ID: 21816746
This should do it.


@echo off

setlocal enabledelayedexpansion
 

for /F "tokens=* usebackq" %%G in (last_line.txt) do set body=%%G
 

blat.exe -subject "A Screen Saver has been Changed" -body "%body%" -to 123@mail.com -i ScreenSaver -priority 1 -server smtp.mydomain.com -f wpdomain

Open in new window

0
 

Author Comment

by:missywpitt
ID: 21816870
when I try and run it it says -subject does not exist.
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 21816889
Oh, I guess the -to switch has to go first.


@echo off

setlocal enabledelayedexpansion

 

for /F "tokens=* usebackq" %%G in (last_line.txt) do set body=%%G

 

blat.exe -to 123@mail.com -subject "A Screen Saver has been Changed" -body "%body%" -i ScreenSaver -priority 1 -server smtp.mydomain.com -f wpdomain

Open in new window

0
 

Author Comment

by:missywpitt
ID: 21816958
Now I got -to does not exist. I think the file itself has to b put after blat? When I run my code I had before it works except I get everything that is in the text file rather than just the last line like I want. Not sure about this one.

I have a work around if we cant get it.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 38

Expert Comment

by:Shift-3
ID: 21817044
After re-reading the Blat documentation (http://www.blat.net/syntax/syntax.html), I'm pretty sure this will work.


@echo off

setlocal enabledelayedexpansion

 

for /F "tokens=* usebackq" %%G in (last_line.txt) do set body=%%G

 

blat.exe - -body "%body%" -to 123@mail.com -subject "A Screen Saver has been Changed" -i ScreenSaver -priority 1 -server smtp.mydomain.com -f wpdomain

Open in new window

0
 

Author Comment

by:missywpitt
ID: 21817200
well that sent me the second line of the text document? Atleast were getting somewhere here.
0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 21817308
Perhaps there is an ampersand or something messing it up.

Last try.


@echo off

setlocal enabledelayedexpansion

 

for /F "tokens=* usebackq" %%G in (last_line.txt) do set body="%%G"

 

blat.exe - -body %body% -to 123@mail.com -subject "A Screen Saver has been Changed" -i ScreenSaver -priority 1 -server smtp.mydomain.com -f wpdomain

Open in new window

0
 

Author Comment

by:missywpitt
ID: 21821426
That worked! Once again Shift-3 you pulled through!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now