Notepad2 Regular Expressions

Notepad2 is an excellent lightweight text editor for Windows – but I had some problems figuring out how to use Regular Expressions to find and replace some repetitive HTML code in a web page.

The code looked like a lot of rows and I wanted to put the link text into the title attribute:
<ul>
<li><a href="some url" title="">Swindon</a></li>
</ul>
A standard perl type regular expression would look like:
search: title="">([a-zA-Z]+)<
replace: title="Homes in $1">$1<

In Notepad2, you have to use a backslash for the backreference:
search: title="">([a-zA-Z]+)<
replace: title-"Homes in \1">\1<

This worked great for me, just a pity they couldn’t have stuck with the dollar sign and done it the way most developers are used to coding.

Run Scheduled Windows VBScript tasks silently

Here’s a quick one.

If you need to run scheduled VBScript tasks on a Windows server, and you don’t want an annoying Command Prompt window popping up every time the task runs, select the task from Start / Control Panel / Scheduled Tasks

In the run setting, make sure that you are specifying the Windows Script Host wscript.exe before the name of your script e.g. wscript.exe “C:scriptname.vbs”

That’s all there is to it.

Logrotate not restarting Apache

Spotted an interesting problem where adding the ‘compress’ directive to logrotate stopped it from doing its daily restart of Apache.

After a bit of diagnosis it turns out that the gzip compression used by logrotate can be very sensitive to non-letter characters in filenames. My log files were all named with an underscore instead of the dot character e.g. access_log instead of access.log.
I think I did this initially to make it easier to find them e.g. locate *_log would give me all the httpd log files I was interested in, instead of locate *.log giving every log file on the system.

I’ve renamed them all back to the more conventional access.log and it is all working as it should.

Lesson learned, don’t try to be too clever in IT.

More on lightweight Linux distros

After some initial experiments with Zenwalk, I have tried 3 more lightweight Linux distros, with the aim of finding something that will run well on an older PC with only 256MB of RAM, but provide a user friendly interface and be capable of performing day to day office tasks.

They are:

Here is my very superficial review, please don’t take it too seriously.

Puppy Linux is the smallest of the three and the ISO file is only 131MB. It is optimized for running from CD or USB. Although it tries to be user friendly it is some way behind the other two for non-technical users. There are lots of strange application names and icons in the menus, so for now I’m putting that aside.

lubuntu is a project that is intended to lead to an official derivative of the Ubuntu operating system that is “lighter, less resource hungry and more energy-efficient”, using the LXDE desktop environment. I installed this to hard disk using an Oracle VirtualBox Virtual Machine.

Pros:
On booting it consumed only 56MB of RAM so there was plenty left over for running applications.
Cons:
It uses chromium as the default browser, and this doesn’t have Adobe Flash installed.

Peppermint OS has the goal of providing a fast, web-centric operating system that’s easy to learn and effective when put in use. The default desktop interface is LXDE. I’ve also run this as a virtual machine.

Pros:
On booting, it consumed 86MB of RAM, a little higher than lubuntu but still very reasonable.
Firefox is the default browser and Adobe Flash is also installed.
There is an update manager that lets you know when package updates are available and a very nice software installer for locating and installing additional applications.
Cons:
I’ll post them here after I’ve spent some more time investigating…

In conclusion Peppermint OS looks like the best option for my requirements at the moment, but it is only through day-to-day use that I’ll uncover any issues.

Installing VirtualBox Guest Additions into Zenwalk

Zenwalk linux is designed to be fast, lightweight and run on older machines (so it is less resource intensive).

That makes it an ideal candidate if you need to run Linux in a Virtual Machine like the excellent VirtualBox.

To install new software into Zenwalk, you need to run Netpkg, and you will probably want to install the VirtualBox guest additions to take advantage of mouse pointer integration. Before installing the guest additions, you will need to install the kernelsource package, which contains the headers you need when the guest additions installer tried to compile.