Listing 2. /etc/ppp/runchat.pl
#!/usr/bin/perl -w
use strict;
$ENV{PATH} = "/usr/sbin";
my $retval;
my $SCRIPT = $ARGV[0];
my $REPORT = '/tmp/runchat.fox';
my $MODEM = $ENV{MODEM};
my $FIFO = $ENV{FIFO};
$| = 1;
if (-e $REPORT) {
unlink $REPORT;
}
`/usr/sbin/chat -f $SCRIPT -r $REPORT <$MODEM >\
$MODEM 2>$FIFO`;
$retval = ($? >> 8);
open STDOUT, ">$FIFO";
# print "\nmessage We ran chat and got retval of
# $retval...\n";
if (!(-z $REPORT)) {
open (REPORT, "< $REPORT") or
die "message can't open $REPORT: $!\n";
while (<REPORT>)
{
if (!(m/$REPORT/)) {
print "\nmessage $_\n";
}
}
close REPORT;
# print "\nmessage now closing $REPORT\n";
}
if (-e $REPORT) {
unlink $REPORT;
}
if ($retval == 3) { print "message TIMEOUT\n"; }
if ($retval == 4) { print "message NO CARRIER\n"; }
if ($retval == 5) { print "message BUSY\n"; }
if ($retval == 7) { print "message NO DIALTONE\n"; }
if ($retval == 8) { print "message WAITING\n"; }
$! = $retval;
Copyright © 1994 - 2019 Linux Journal. All rights reserved.