rblog

Black Rose in Oslo

Black roses (roses of black color) do not exist in nature. They are often featured in fiction with many different meanings and titles such as black magic, barkarole, black beauty Tuscany superb, black Jade,” and baccara and death varieties of roses.

More to be found at
http://en.wikipedia.org/wiki/Black_rose_%28symbolism%29

Not sure if the truck driver has thought of the same symbolism when spray painting the truck which I saw outside my office building today.

This weekend in Tromsø

Spent the weekend in Tromsø celebrating my first cousin Andre, he turned 40 about a month ago. I also got to visit my friend Kent, always a pleasure. Sunday, lovely weather in Tromsø, Kent is giving the garden shredder a hard time.

Also testing the pogo stick
[video:youtube:NHfCYyVa2us]
After work what tastes better than black crowberry lemonade? “Krøkebærsaft” from http://midnattsolprodukter.no – worth the money.

Excel 2007 – Conditional Formatting: Compare 3 columns with text – find unique values

Raised a question at Superuser.com which got answered in just a few seconds, see http://superuser.com/questions/488367/excel-2007-conditional-formatting-compare-3-columns-with-text-find-unique-v

The magic was achieved by using Conditional Formatting and adding a formula =COUNTIFS($A:$C;A1)<=2. Still having some issues, seems to be caused by me having imported the text from csv-files. Might be that if all had been typed in it would have worked without errors. Maybe need a newer version of Excel…

Windows .bat-file that stops and starts services, kills processes and rename files

Needed to automate rotation of the IBM WebSphere HTTP Server plugin log-file, and in addition I needed to make sure that all processes of rotatelogs.exe have been stopped. This due to a bug in Apache for Windows, at least old versions, where the rotatelogs.exe processes does not end while restarting Apache. In addtion I wanted to make the script working for both our IBM HTTP Server v 6.1 and 7.0 servers. Could off course just edit the script based on which server, but hey…coming from a Linux environment and using bash-scripting, I wanted to test out what could be done on Windows.

Must admit that I hate the GOTO’s and also I find the scripting language itself a pain. I realize that I need to dive into the Powershell, see this table on Wikipedia showing what I really love – commands equal to Unix/Linux, yeah man!!!

Anyhow, here is the script I have created.


:: See https://apps.klp.no/confluence/display/FILENET/Administration+-+IBM+HTTP+Server+%28Apache%29#Administration-IBMHTTPServer%28Apache%29-Logrotation
ECHO off
:: Get the hostname of server as a variable
:: http://stackoverflow.com/questions/998366/how-to-store-the-hostname-in-a-variable-in-a-bat-file
FOR /F "usebackq" %%i IN (`hostname`) DO SET _HOSTNAME_=%%i

:: ***************************
:: Stop the IBM HTTP Server 
:: ***************************
:: Which version is installed
:: http://stackoverflow.com/questions/9445223/how-to-check-in-windows-xp-if-the-service-is-not-installed-using-batch-file
sc query IBMHTTPServer7.0  | find "IBMHTTPServer7.0" >nul
IF ERRORLEVEL 1 GOTO STOP_AS_61SERVICE
ECHO Stopping service named IBMHTTPServer7.0
sc stop IBMHTTPServer7.0 >nul
GOTO END_OF_STOP
:STOP_AS_61SERVICE
:: Is version 6.1 installed?
ECHO Did not find IBMHTTPServer7.0 service, trying IBMHTTPServer6.1 
sc query IBMHTTPServer6.1  | find "IBMHTTPServer6.1" >nul
ECHO Stopping service named IBMHTTPServer6.1
sc stop IBMHTTPServer6.1 
GOTO END_OF_STOP
:NO_WEB_SERVICE
ECHO Not able to find the IBM HTTP Service
GOTO TotalFailure
:END_OF_STOP

:: Sleep for 30 seconds
:: http://stackoverflow.com/questions/4317020/windows-batch-sleep
ECHO 
ECHO Sleep for 30 seconds ....
ping -n 30 127.0.0.1 >nul


:: ***************************************
:: Kill all instances of rotatelogs.exe
:: ***************************************
ECHO Kill all pending rotatelogs.exe processes
taskkill /F /IM rotatelogs.exe 2>nul

:: ***************************************
:: Rotate the http_plugin.log
:: ***************************************
cd D:\HTTPServer\Plugins\logs\ 2>nul
IF ERRORLEVEL 1 GOTO IBM_HTTP_61_FOLDER
GOTO Rename
:IBM_HTTP_61_FOLDER
ECHO cd D:\HTTPServer61\Plugins\logs\
cd D:\HTTPServer61\Plugins\logs\
IF ERRORLEVEL 1 GOTO TotalFailure

:Rename

for /f "tokens=5 delims=\" %%I in ('dir /S /B http_plugin.log') do for %%A in (%%~I) do (
	ECHO Name of folder where http_plugin.log is found: %%A
	cd %%A
	ren http_plugin.log http_plugin-%date:~0%.log
	IF ERRORLEVEL 1 GOTO RENFAIL
	ECHO File has been renamed to http_plugin-%date:~0%.log
	cd ..
)
GOTO RENAME_END
:RENFAIL
ECHO Failed to rename http_plugin.log, exit
GOTO TotalFailure
:RENAME_END

:: ****************************
:: Start the http-server
:: ****************************
:: Is version 7 installed?
sc query IBMHTTPServer7.0  | find "IBMHTTPServer7.0" >nul
IF ERRORLEVEL 1 GOTO START_AS_61SERVICE
ECHO Starting service named IBMHTTPServer7.0
sc start IBMHTTPServer7.0
GOTO END_OF_START
:START_AS_61SERVICE
:: Is version 6.1 installed?
:: If 6.1 is not installed, the stop will got to totalfailuere
ECHO Did not find IBMHTTPServer7.0 service, trying IBMHTTPServer6.1 
sc query IBMHTTPServer6.1  | find "IBMHTTPServer6.1" >nul
ECHO Starting service named IBMHTTPServer6.1
sc start IBMHTTPServer6.1 
:END_OF_START
:: Return to current directory
:: http://weblogs.asp.net/whaggard/archive/2005/01/28/get-directory-path-of-an-executing-batch-file.aspx
cd /d %~dp0
exit /b

:TotalFailure
:: Return errorcode
:: http://www.robvanderwoude.com/errorlevel.php
cd /d %~dp0
ECHO Failed, have to exit
ECHO 1 | CHOICE /C:1234567890 /N