Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jjohn (22)

  (email not shown publicly)
AOL IM: taskboy3000 (Add Buddy, Send Message)

Perl hack/Linux buff/OSS junkie.

Journal of jjohn (22)

Thursday March 04, 2004
09:47 AM

Hillary is my new love

[ #17752 ]
My trusty computer companion of the last five years, Marian, has been replaced by a new hottie, Hillary. Marian, an aging celeron 400Mhz/256M/40G running RedHat 7.3, serviced me well, doing sendmail/fetchmail/web/mysql/perl developement chores. But times change and so must I. Hillary is a Athlon XP 2600 Barton 1.9Ghz/512M/80G RedHat 9.0 system that now runs everything like Marian used to -- BUT FASTER. So, hail Hillary.

A few notes:

  • My initial experiences with RedHat 9.0 bolster my long standing suspicion that RedHat hates Perl. Out of the box, perl 5.8.0 had trouble writing makefiles. This is related to a unicode issue that may be solved by setting one's environment variable to LANG=en_US. Rasberries to RedHat.
  • New Egg is a good place to buy computer parts CHEAP. I assembled Hillary from parts costing $343, including shipping & handling. The 400W power supply came with the LED-enhanced mid-tower case for $29. I bought the Biostart motherboard (LAN/Video/Audio on board) for $56. The CPU was $90. The 512MB DRR PC-2100 RAM was $72. The 80G Maxtor/ATA133 was $66. Good stuff. Unforuntately, debian's current stable release, Woody, is too freakin' old to recognized the onboard LAN. This makes it hard to use apt-get. Perhaps the fine folks running debian might consider shipping a 2.4 kernel before the 2.6 comes out. Woody ships with a 2.2 kernel from 2002.
  • I've taken to keeping a lot of system-y things in my home directory, like my DNS files and mon. This turns out to be really useful when you need to rsync your home directory. I also have a crazy perl script that starts personal services, like ssh tunnels, VNC, apache and mon. As a kind of a kludge, a cron job attempts to rerun the script every 2 minutes to make sure that these services are running, even if the machine is rebooted. I've included the script below, in case someone is interested. It's essentially a steroid-enhanced version of a shell script.

File: setup_jjohn

#!/usr/bin/env perl
# -*-cperl-*-
# start|stop processes that I need
use strict;
use warnings;
use File::Basename;
use Getopt::Std;

our $HOME    = "/home/jjohn";
our $LASTRUN = "$HOME/etc/.jjohn_setup";

our %PROCS = ( '01 SSH tunnels' => { start => "$HOME/etc/ssh_mail_tunnel start",
                                     stop  => "$HOME/etc/ssh_mail_tunnel stop",

               '02 MON' => { start => "$HOME/etc/mon/start_mon",
                             stop  => "killall mon",

               '99 VNC' => { start => "$HOME/bin/start_vnc",
                             stop  => "/usr/bin/vncserver -kill :1",

               '04 Fetchmail' => { start => "/usr/bin/fetchmail",
                                   stop  => "killall fetchmail",

               '03 Apache'=> { start => "/usr/bin/sudo $HOME/src/apache-current/bin/apachectl start",
                               stop  => "/usr/bin/sudo $HOME/src/apache-current/bin/apachectl stop",


my $opts = {};
getopts('h?fv', $opts);

my $action = (lc pop @ARGV) || 'start';
my %dispatch = ( 'stop'   => \&stop,
                 'start'  => \&start,
                 'usage'  => \&usage,
                 'status' => \&status,

$action = 'usage' if $opts->{'?'} || $opts->{'h'};

if (exists $dispatch{$action}) {
} else {


#-------------------------------------------------- -------------------

sub start {
  my ($opts) = @_;

  # Skip the LASTRUN check if the force flag is set
  unless ($opts->{f}) {

    # compare the boot time (/var/lock/subsys/local) to our last runtime
    if (-e $LASTRUN) {
      my $sysboot = (stat "/var/lock/subsys/local")[9];
      my $lastrun = (stat $LASTRUN)[9];

      # if we have run after system boot, bail
      if ($lastrun > $sysboot) {
        warn "Already ran since boot.  Halting.\n" if $opts->{v};

  for my $proc (sort keys %PROCS) {
    printf "Starting %-25s:", $proc if $opts->{v};

    my $ok = "OK";
    if (system("$PROCS{$proc}->{start} 2>&1 > /dev/null")) {
      $ok = "FAILED";
    printf "%15s\n", $ok if $opts->{v};

  # print out PID to LASTRUN
  open my $pid, ">$LASTRUN" or die "can't open '$LASTRUN': $!\n";
  select(((select $pid) => $|++)[0]);
  print $pid $$;
  close $pid;


# stop the services above
sub stop {
  my ($opts) = @_;

  for my $proc (reverse sort keys %PROCS) {
    printf "Stopping %-25s:", $proc if $opts->{v};

    my $ok = "OK";
    if (system("$PROCS{$proc}->{stop} 2>&1 > /dev/null")) {
      $ok = "FAILED";
    printf "%15s\n",$ok if $opts->{v};

  unlink $LASTRUN;

sub usage {
  my $name = basename $0;
  print "$name - control services for jjohn


  $name [OPTIONS] [ACTION]
  \$ $name -v start # start services with verbosity
  \$ $name stop     # stop services silently
  \$ $name status   # show boot time vs. last run of this program


  h  print this screen
  ?  print this screen
  f  force start, regardless of LASTRUN file
  v  turn on verbose messages

sub status {
  my ($opts) = @_;
  my $lastrun = (stat $LASTRUN)[9];
  my $boot    = (stat "/var/lock/subsys/local")[9];
  my $name    = basename $0;

  my $ltime = (defined $lastrun)
              ? scalar localtime($lastrun)
              : "NEVER RUN";

  my $btime = scalar localtime($boot);

  printf "%16s: %-20s\n%16s: %-20s\n",
          "system boot", $btime,
          "$name ran", $ltime;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I second the vote for New Egg -- I've bought from them a few times (as have my coworkers) with excellent results -- fast and cheap is a good combo.
    • I think is also excellent on media,memory,ink and cases. Meritline is the best place for me to buy DVD media. They have the lowest prices by far. They need to offer free 2nd day like others or atleast free ground shipping. I love Meritline. I bought 150 Verbatim DVD R disks for an average of 23 cents a piece. I challenge anyone to beat that from any other store. Meritline is the best place to buy stuff for all your recording and labeling needs. They even sell ink for cheap. I have ordered