Monday, 29 June 2009

Send smtp emails from command line (bmail.exe)

I've discovered a free command line tool which sends SMTP emails from a command line and therefore can be used within batch files. It can also take environment variables as parameters. For example, to send an email when a server is booted, create a batch file with the following line:
bmail.exe -s 192.168.1.7 -t admin@domain.com -f helpdesk@domain.com -a "%computername% has just booted" -b "The computer has started up. Please investigate."
You can then just copy the batch file and bmail.exe to your SYSVOL folder on the domain controller(s) and create a GPO to run the batch file on startup.

You can obtain the tool from the following webpage: http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm

Wednesday, 17 June 2009

Watch command for Windows

One of the things I like about Linux/Unix is that there are far more (and better) command-line tools available than the ones you get by default with Windows. One of the commonly used tools is 'watch' which simply repeatedly runs another command until you quit. This is useful for things like displaying the current contents of a log file, or maybe doing a directory listing so you can watch it to see when something has changed. As far as I know there is nothing similar in Windows so I wrote my own batch file which does the same thing:
@echo off
title Watching %1 %2 %3 %4 %5
:top
cls
%1 %2
%3 %4 %5
echo.
choice /C QC /M "Press Q to quit or C to continue" /t 3 /d c
if errorlevel==2 goto top
if errorlevel==1 goto end

:end
If you want to use it, copy the script above into a file called 'watch.cmd' and place that file somewhere in your path, e.g. C:\Windows\System32.

What happens in the script above is basically that the 1st parameter you supply would be the command to run and the following 4 parameters would be any switches or values you want to provide. Up to 4 extra switches can be provided although you can obviously change this to be as many as you like. The choice command provides a 3-second delay and gives you the chance to quit watching by pressing q or continue immediately by pressing c — rather than waiting for the 3 seconds to elapse. Again, you can change the timeout from 3 seconds by changing the /t 3 value to something else.

Now, say you want to monitor the output of a file named 'C:\error.log'. Use the command by entering watch type c:\error.log and the file will be repeatedly typed on the console screen at 3 second intervals until you press q.

Easy!

Monday, 15 June 2009

Orange Internet settings for a mobile

If you have an Orange SIM and an unlocked phone, or you need to get the internet settings so your phone can access the internet on Orange's GPRS or 3G network, visit the following website and enter your phone model and phone number. You will be texted the settings which will automatically be set up for you. The link is http://setuporange.wdsglobal.com/internet