Re: Reseting modem (fwd)

Dave Andersen (angio@aros.net)
Thu, 19 Sep 1996 02:04:23 -0600

> At 09:57 PM 9/17/96 -0700, you wrote:
> >
> >Write a Perl script to connect to the PM and issue a 'reset s#' to the idle
> >ports and run it as a cron job.
> >
> >-MZ
> >--
>
> If someone who is proficient in perl does this, I'd sure appreciate seeing
> the script.

It's appended at the end of this message. Be warned - unlike the rest of
my scripts, this program *must* run with the latest version of pmcom
(NOT the one I wrote. :)

The only configuration that's necessary is setting your portmaster's
names in the @portmasters array, and pointing to the location of pmcom.

It's included because it's really quite short.

> On a related note (since I haven't bought my copy of "perl for dummies"
> yet, I'm having a problem with Dave Anderson's "Summarize" script that provides
> a summary of usage from the radius logs after being massaged by his "line
> parser"
> utility.

Heh. Buy the book. :) Or buy "Learning Perl" and "Programming Perl",
published by O'Reilly & Associates. Like most of the ORA books, it's
an invaluable reference.

> The summary script just hangs. Any ideas what I may be doing wrong?

How're you invoking it?

-Dave Andersen

#!/usr/bin/perl

# Use at your own risk. I've never had a problem with it, though.

@portmasters = ('pm1', 'pm2'); # put yer portmasters here

$Pmcom = "/home/angio/src/portmaster/pmcom";

foreach $pm (@portmasters) {
open(PMCOM, "$Pmcom -c $pm 'show sess'|") || next;
undef(@ports);
while (<PMCOM>) {
if (!/^S/) { next; }
if (/IDLE/) {
($port, $junk) = split;
# print "Resetting $pm $port\n";
push(@ports, "$port");
# print RESET "reset $port";
}
}
close(PMCOM);
open(RESET, "|$Pmcom $pm -") || next;
foreach $port (@ports) {
print RESET "reset $port\n";
print "Reset $pm $port\n";
}
close(RESET);
}