#!/bin/sh
# -*- perl -*-
# This code allows us to start perl from our path or an environment variable
# rather than hardcoding a path into the #! line.  It works from sh or csh.
(exit $?0) && eval 'exec ${QPERLQ-perl} -x $0 ${1+"$@"}'
if (! $?QPERLQ) setenv QPERLQ perl
exec $QPERLQ -x $0 $argv:q

#!/usr/local/bin/perl -w
#
# $Id: apm_status,v 1.2 1998/02/05 21:07:37 ejb Exp $
# $Source: /home/ejb/scripts/RCS/apm_status,v $
# $Author: ejb $
#

require 5.002;
use strict;

my $whoami = ($0 =~ m,([^/\\]*)$,) ? $1 : $0;
#my $dirname = ($0 =~ m,(.*)[/\\][^/\\]+$,) ? $1 : ".";

my $search = $ENV{'SEARCH'} || "/home/ejb";
push(@INC, "$search/source/perl/modules");
require LinuxAPM;

if ((@ARGV == 1) && ($ARGV[0] eq "--help"))
{
    &usage(0);
}

my $apm_file = LinuxAPM::apm_file();
if (! -f $apm_file)
{
    print "$whoami: $apm_file does not exist; unable to get APM status\n";
    exit 0;
}

my $verbose = 0;
while (@ARGV)
{
    my $arg = shift(@ARGV);
    if ($arg eq "-v")
    {
	$verbose = 1;
    }
    else
    {
	&usage(2);
    }
}
    
my $apm = new LinuxAPM($verbose);
print $apm->printable_status();

sub usage
{
    my $status = shift;
    if ($status == 0)
    {
	open(OUT, ">&STDOUT");
    }
    else
    {
	open(OUT, ">&STDERR");
    }
    print OUT "Usage: $whoami [ -v ]\n";
    exit $status;
}
