troubleshooting Question

VBS Script for email header IP

Avatar of purpleoak
purpleoakFlag for United Kingdom of Great Britain and Northern Ireland asked on
VB Script
3 Comments1 Solution460 ViewsLast Modified:
I need to right a VBS script that can have a text document passed to it, then it reads through the text document and looks for the last occurrence of Received From: ([127.0.0.1]) and adds a new line to the text file saying Originating-IP: 127.0.0.1

The command to run the VBS would need to be "extractIP.vbs 123454343454.txt" ie the text file to check through is specified. An example text from the file is the following.

Received: from mailfilteruk.com ([192.133.7.42]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:11:08 +0100
Received: from modernwebsites.myvirtuozzo.com ([192.133.7.32]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:09:58 +0100
Received: from modernwebsites.co.uk ([64.151.225.132] helo=modernwebsites.myvirtuozzo.com)
      by MFS032F.mailfilteruk.com with ESMTP (2.0.1); 19 May 2011 16:06:05 +0100
Received: from host86-163-57-254.range86-163.btcentralplus.com ([86.163.57.254] helo=damien-intel.home)
      by modernwebsites.myvirtuozzo.com with esmtpsa (TLSv1:AES256-SHA:256)
X-Originating-IP:86.163.57.254


As you can see there are several received from IP address, the one i need however is the last one in bold. To further complicate the issue the IP will be different each time so it will need to look for the last instance of received from: ([

It will then add the following string. X-Originating-IP:86.163.57.254 to the line after the received from line.

So it would then look like the following.

Received: from mailfilteruk.com ([192.133.7.42]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:11:08 +0100
Received: from modernwebsites.myvirtuozzo.com ([192.133.7.32]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:09:58 +0100
Received: from modernwebsites.co.uk ([64.151.225.132] helo=modernwebsites.myvirtuozzo.com)
      by MFS032F.mailfilteruk.com with ESMTP (2.0.1); 19 May 2011 16:06:05 +0100
Received: from host86-163-57-254.range86-163.btcentralplus.com ([86.163.57.254] helo=damien-intel.home)
      by modernwebsites.myvirtuozzo.com with esmtpsa (TLSv1:AES256-SHA:256)
X-Originating-IP:86.163.57.254

I hope that all makes sense.
ASKER CERTIFIED SOLUTION
Darren Collins
Tech Lead (Windows), Endpoint Device Management Services

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros