Note: Technical Talk being moved to:

Wednesday, 30 March 2011

Tuesday, 29 March 2011

DOS Script to Email Results of a Database Export

Had to write a batch script to check on the status of a nightly database export and email status. Some of what I've done may not be perfect, but it does the job nicely and portions can be reused, hence it's appearance on this blog for future reference.

REM Enable local environments to be changed without affecting anything else.

REM check the export.log file for the filedate and pass it into a variable. Done by doing a directory listing on the file, returning just the filename and then looping through and capturing the file's timestamp into a variable

for /f "tokens=* delims=" %%a in ('dir/b export.log') do (
for /f "tokens=1 delims=" %%i in ("%%a") do (
set _fdt=%%~Ti

REM Write the logfile contents to a secondary file. This is only done to allow us to append the results of a TSM tape backup of the export.dmp to a logfile and email it in the email body.

type export.log > bkup.log

REM set a variable _status with a default of ERRORS. If the process has a status of SUCCESS, the following commands will overwrite this variable. If not, it will report it as ERRORS in the email

SET _status=ERRORS

REM Loop through the earlier generated secondary logfile and find the string "Export terminated successfully without warnings" which is a standard Oracle output found in export logs

for /f "tokens=*" %%s in ('type bkup.log ^| find /i "Export terminated successfully without warnings"') do (SET _status=SUCCESS)

REM Processes to follow a SUCCESS which includes sending the export.dmp to TSM tape storage. Append the TSM results to the secondary logfile generated earlier.
if %_status%==SUCCESS (
cd \TSM\baclient\
dsmc archive -des="TSM Archive Name %_fdt%" -archmc=ARCH14D export.dmp >> bkup.log

Use a third party application, postie to email the results

c:\postie\postie -host:mailhost -s:"SUCCESS:ExportDaily (%USERDOMAIN%) for %_fdt%" -nomsg -file:bkup.log

REM Email as ERRORS if the above step fails

if %_status%==ERRORS c:\postie\postie -host:mailhost -s:"ERRORS:ExportDaily (%USERDOMAIN%) for %_fdt%" -nomsg -file:D:\backup\obj_live\bkup.log

Friday, 18 March 2011

Alter Database Open Resetlogs Upgrade

Had to restore a database to a point-in-time from a hotbackup.  Followed Steps:

  1. Copied datafiles to target
  2. Created a New Controlfile
... and that's when the wheels fell off, with the database instance terminated and errors in the alert log advising startup upgrade needs to be done.

The reason for this is that the target database was upgraded sometime after the point in time recovery date.

In the past, when faced with this situation, I was able to point the database and the /etc/oratab entries to the old Oracle Home and recover that way, but in this instance the old home had been removed and well a more elegant solution needed to be found.


  1. Copied datafiles to target
  2. Created a New Controlfile
The next step is to then apply the upgrade scripts and breathe a sigh of relief!

Friday, 11 March 2011

Meeting Jeff Thomson

"Ashes to ashes, dust to dust; if Lillee don't get you Thommo must!"

Had the opportunity today of meeting Jeff Thomson at a function, where he was guest speaker.  At 60 years of age, Thomson is an unassuming, very likeable, down-to-earth bloke.

The first half of the evening was rather a let down, as Thomson delivered jokes that wouldn't have been much funnier at the hands of a professional stand-up comedian.  However, he more than made up for the light hearted banter with some insightful comments about his career.

His anecdotes relating to his good friend Len Pascoe were hilarious, though I shan't bother repeating them here, as "you had to be there".

Most interesting was the Q&A session, where a lot of interesting information was gleaned.  I personally asked him two questions (paraphrasing):

Q.  Did you ever feel like you were playing second string to Dennis Lillee and what was your relationship with Lillee like?

A.  Lillee and I were good mates.  I used to scare the sh*t out of batsmen and then Lillee would do his thing and get the wickets.  It was a great partnership, which later on was mirrored in the partnership between McGrath and Warne.  All I ever wanted to do was bowl fast.

Q.  Who do you think will win the world cup this year?

A.  I reckon Australia are a good chance.  They've not lost anything so far and if Hussey is in form, they should do well.  India are not that special.

Other snippets of information gleaned from the Q&A included the following.  Please note, I did not take notes and am just recalling from memory what was said.  Some of what was mentioned, may have been misinterpreted by myself, so if you want Thomson's personal opinion on any of these matters, don't quote me, ask the man yourself (Is that a decent enough disclaimer for the dirt I'm about to dish out?)
  • Hilditch is likely to be offered another 2 year extension of contract as Selector, which is bad news for Australian cricket.
  • Ponting has his favourites and as a result talented players like Brad Hodge have not had a decent run in the team.
  • Michael Clarke is not liked by the players and the selectors would rather have as captain someone such as Tim Paine.
  • Thomson doesn't rate Phil Hughes as a test calibre batsman and would rather see someone like David Warner given a chance to play test cricket.
  • From the current crop of players, he rates Brett Lee the highest.  Does not appear to have any time for the likes of Tait, Siddle or Mitchell.
  • In his opinion, most bowlers don't spend enough time honing their craft on the cricket pitch.  As an example, Steve Finn when not picked for England, was sent off for strength and conditioning instead of playing cricket for his county side.  Thomson feels that the only way to get the best out of bowlers is to have them bowl a lot.
  • His role model was "his dad" and guys such as Fred Trueman.
Pardon the paunch - I should've worn black, as I'm told it's more slimming (doubt it would've helped much though)


MySQL Spool File

Thanks to my friend LW for helping sort this one out.

You can increase the verboseness (is that a word?) of a batch output logfile in MySQL, by repeating the "-v" switch.

This is amazingly useful if for example you are running some DML and wish to capture in your output logfile the number of rows being inserted/deleted/updated.

mysql -u user -ppassword database_name -v -v < test.sql > test.log

Thursday, 10 March 2011

Lightening Strikes Thrice!! (Warning: Disturbing Images)

AAARRRGGG!!!! Today for the third time, in a lifetime of keeping fish, I've lost my entire colonies of happy, healthy, breeding fish. This time to equipment failure. Murphy's Law being what it is, these things always happen in the dead of night when no one is around to notice of course.

My primary air-filter stopped working and the secondary didn't have enough juice to keep the fish alive, as the population in my tank, through breeding was starting to get out of control. My own fault of course, for not thinning them out and there is only so much equipment that can be added to a tank!

Anyhow, just lost an array of fantastic fish including Frontosas, Duboisies, Mainganos, Electric Yellows. The only survivors, my clown loaches, bristlenose catfish and one or two hybrid cichlids, which may not live through the day :(

Not sure what to do now, may just give the survivors to a friend and call it a day!