Now running latest version, 4.1.6 of B2Evolution, easy as always to keep up to date with the latest features and security patches.
rblog
Jython – Unpack the manifest-file from a jar on the Windows platfom
Decided to create a script based on Jython v 2.1 (WebSphere comes with that version) that finds all third party jar-files packed in a EAR-file. When found I also needed to read the MANIFEST.MF-file to figure out the version of the jar. To accomplish this I needed to execute jar.exe to be able to extract the manifest file, when that is done I can read the line implementation-version in the file.
First, import the needed Java-classes
import java.lang.ProcessBuilder as ProcessBuilder
import java.lang.Process as Process
Then in the script
pb = ProcessBuilder(['cmd.exe', '/C', 'd:/WebSphere/AppServer/java/bin/jar.exe','xvf', 'd:/path/lib', 'META-INF/MANIFEST.MF']);
pb.directory(io.File('d:/temp'))
process = pb.start()
process.waitFor()
process.destroy()
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
Verify Windows service status from command line
The command to use is sc. First you need to know that every service has a display name and a service name. I banged my head into the wall until I realized that I could just type sc query to list all. Actually I typed sc query >> result.txt
Then I found the real name of the IBM HTTP Server 6.1-service and I could type
D:\HTTPServer61\bin>sc query IBMHTTPServer6.1
SERVICE_NAME: IBMHTTPServer6.1
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
Blog engine upgraded to latest version
Yet again upgraded to latest version, now running 4.1.5b, easy to do, took me about 10 minutes including download of the changed files and uploading them to the server. http://b2evolution.net/ rocks!
Online again
My blog is yet again up and running after about two days of downtime. The issue has been related to my ISP having moved my domain to another server. This caused http://hellem.org to reply with another ip than http://www.hellem.org. In addition the database server had been moved so I had to update the configuration files to the blog.
But, now back again!
Summarize disk usage of all files of a given type
Needed to know how much disk space all *.ear-files was consuming in a directory on one of our Linux-servers
find . -type f -name "*.ear" -exec ls -l {} \; | awk '{print $5}' > sum.txt
awk '{ sum += $1 } END { print sum }' sum.txt
Then I used Google to make the number human readable, https://www.google.no/search?q=9606676582+bytes+to+gb
FB – 500 server error
X11 Forwarding and su/sudo
Ever been in the situation where you log on to a server as one user having X11 enabled, but then need to sudo to another one – and voila, your X11-sesison is long gone…
Solution provided here http://brandonhutchinson.com/wiki/X11_Forwarding_and_su/sudo
I did as root
cd ~
mv .Xauthority .Xauthority_old
ln -s ~diagnostics/.Xauthorithy .Xautorithy
and it all worked fine.
