Web front-end for Power Manager

So far, Power Manager does not have a web base interface. In today's world of Web 2.0 this is clearly a must — even for our software. :-)

Pending events in a browserPending events in a web browser

For those that can not wait, below is a Perl CGI snippet that displays your pending events in a web page. Not pretty but functional; adding CSS and formatting is easy and left as an exercise.


use strict;
use warnings;
use CGI;

my $pmctl = '/usr/local/powermanager/bin/powermanagerctl';

# Ask powermanagerctl for the pending events in Perl format
my $events = `$pmctl -f perl notifications.pending`;

# Evaluate response to return a easy to traverse structure
my $var1 = undef;
eval("\$var1 = $events");
die("Oops, $@\n") if ($@);

# Turn the pending events into a simple web page
my $cgi = new CGI;
print $cgi->header;
print $cgi->start_html('Power Manager - Pending');
print $cgi->h1('Pending Events');

# Print one line for each pending event
foreach my $event (@$var1) {
    print $cgi->p(
        $$event{'name'}.' - '.
        $$event{'trigger'}{'date'}.' - '.

print $cgi->end_html;

For those new to running Perl CGI scripts on a Mac, the following online book is a great starting point, CGI Programming With Apache and Perl on Mac OS X.

The script above uses the command line interface to Power Manager and the flag -f Perl. The -f flag formats the output in ready-to-evaluate Perl code.

I recommend exploring the possibilities of powermanagerctl. You have complete control over Power Manager and can combined it with your favourite UNIX tools.

Having command line access to your schedule is great fun. It opens up endless possibilities. In this case a fairly plain web page, but in the real world being able to script event information directly is a great time saver.

Have fun.

This article was posted in and tagged .

Published by Graham Miln on