#!/usr/bin/perl -w
# Copyright 2000 Ry4an Brase (ry4an at ry4an dot org)
use IO::Handle;
use strict;
use POSIX qw|setsid|;
my $initString = "ATE1V1Q0#CID=1";
#my $initString = "ATE1V1Q0+VCID=1";
my $modem = "/dev/modem";
my $filterProgram = "./cidfilter.pl";
my $verbose = 0; # set this to true if you wanna see chatter
(open OUTGOING, ">$modem") || die "Unable top write to modem: $!\n";
(open INCOMING, "<$modem") || die "Unable top read from modem: $!\n";
OUTGOING->autoflush(1);
INCOMING->autoflush(1);
print "Initializing....";
print OUTGOING "$initString\r";
while (<INCOMING>) {
s/(\s*)$//;
print "Heard: '$_'\n" if ($verbose);
last if ($_ eq 'OK');
}
close OUTGOING;
print "Done\n";
my @params = ($filterProgram);
while (<INCOMING>) {
s/(\s*)$//;
print "Heard: '$_'\n" if ($verbose);
next if ($_ eq '');
if ($_ eq 'RING') {
if (@params > 1) {
defined(my $pid = fork) or die "Can't fork: $!\n";
if ($pid) {
$SIG{CHLD} = 'IGNORE';
@params = ($filterProgram); # parent;
next;
} else {
#child
$SIG{CHLD} = 'DEFAULT';
exec @params;
exit;
}
}
next;
}
unless (s/\s+=\s+/=/) {
print "Can't Process: '$_'\n";
next;
}
push @params, $_;
}
Generated by GNU enscript 1.6.1.