Showing posts with label Bat. Show all posts
Showing posts with label Bat. Show all posts

Thursday, February 25, 2010

Blat - A mailing utility

Often developers/testers come across scenarios where in they have to notify a team once a deployment or build is complete. There are many build management tools that provide us with such an option. There could be scenarios where in Maven or Ant is used for building purpose. In such scenarios emailing options should be considered through a third party tool. One such tool is "BLAT"

Blat is a Win32 command line utility that sends eMail using SMTP or post to usenet using NNTP. SMTP being the protocol that we use for email communication, Blat provides us with the option to send mails to the intended recipients.

Doing it the ANT way

Assuming your build process is setup using Ant and the last step that you want to do is to send an email. This is how to write an Ant target to achieve the same

  <target name="email-report">
         <exec dir="${basedir}"
          executable="${basedir}/../thirdparty/blat/blat.exe"
          os="Windows XP,Windows 2000,Windows 2003,Windows Server 2003,Windows Server 2008">
               <arg file="<location of the file you want to send as an attachment if any>"/>
               <arg line="-to <email address of the recipient>"/>
               <arg line="-f  <email address of the sender>"/>
               <arg line="-server <the SMTP server address>"/>
               <arg line="-i <email alias name>"/>
               <arg line="-s <'your subject within single quotes'>"/>
         </exec>
  </target>

Doing it the BAT way

Suppose if you have automated ur build process using batch script invoking specific goals or target and would like to also trigger mails from the batch, here is how you go about it.

<Location where blat is installed>\blat.exe "Attachment if any" -to "Recipient Email address" -f "Senders Email address" -i "Sender Email Alias" -s "Subject Line" -server "SMTP Server address"

This is a very simple email utility that not many of us know about. Happy mailing :)

Sunday, January 24, 2010

Wanna change network settings to work at different locations?

People working with laptops might have to swap the network settings depending on the location they work at. Normal usage being at Home and at Work. At work places these settings are normally defined by the DHCP and at home its a STATIC source most of times.

I have come up with a batch script using which you can switch between these network settings without having to change them manually whenever your work location changes. All that has to be done to copy the below script into a file and name it *.bat and just double click it. You might have to key in your work location as an arg when you run this.

Don't forget to define the following variables varip, varsm, vargw, vardns1 and  vardns2 with your network specific entries. (Your service provider must have provided you with these entries)

 ******** COPY THE SOURCE BELOW ********

@ECHO OFF

ECHO Change network setting for (Home/Work)?

set/p "cho=>"

if %cho%==Home goto HOME
if %cho%==HOME goto HOME
if %cho%==Work goto WORK
if %cho%==WORK goto WORK

:HOME
set varip=

set varsm=

set vargw=

set vardns1=

set vardns2=

REM ***** You don’t need to change anything below this line! ******

ECHO Setting IP Address and Subnet Mask

netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%

ECHO Setting Gateway

netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1

ECHO Setting Primary DNS

netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%

ECHO Setting Secondary DNS

netsh int ip add dns name = "Local Area Connection" addr = %vardns2%

GOTO DISPLAY

:WORK

ECHO Setting IP Address

netsh int ip set address name = "Local Area Connection" source = dhcp

ECHO Setting DNS

netsh int ip set dns name = "Local Area Connection" source = dhcp

GOTO DISPLAY

:DISPLAY

ECHO Here are the new settings for %computername%:

netsh int ip show config

pause.