#!/usr/bin/perl $total_dialed = 0; $logfile = 'test.log'; # load call recs &get_recs('testdata2'); exit; ################################################################## # Actual Dial Sub - Where most of the real stuff happens ################################################################## sub dial { $res = my_create_outgoing($phone); if ($res) { print "Dialing: $phone\n"; $total_dialed++; } # &write_log(stamp(), $phone, $res, $logfile); } ################################################################### # Just Pulling Records from a File ################################################################### sub get_recs { my ($filename) = @_; $recinc = 0; open(TEXT, "<$filename") || die "Cannot open $filename: $!\n"; while ($string = ) { chomp($string); # remove any quotes $string =~ s/\"/ /g; if ($string) { $recinc++; print "(" . $recinc . ")"; &dial($string, 'queue'); } sleep(0); } close(TEXT); } #################################################################### # Silly Log Crap #################################################################### sub write_log { my ($l_total_dialed, $l_phone, $l_res, $l_logfile) = @_; open (LOGUSER, ">>$l_logfile"); print LOGUSER "$l_total_dialed|$l_phone|$l_res\n"; close (LOGUSER); } #################################################################### # YYYYMMDDHHMMSS datetimestamp #################################################################### sub stamp { ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = (localtime(time))[0,1,2,3,4,5,6,7,8]; $mydatetimestamp = sprintf("%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d%6.6d", $year+1900, $month, $mday, $hour, $min, $sec, rand(999999)); return $mydatetimestamp } #################################################################### # Alternate Outgoing Code #################################################################### sub my_create_outgoing { my ($o_phone, $o_how) = @_; my $outdir = '/var/spool/asterisk/outgoing'; my $filename = $outdir . '/' . stamp() . '.outgoing'; open(OUTFILE, ">$filename") || return 0; flock(OUTFILE, LOCK_EX); print OUTFILE "Channel: Zap/g2/" . $o_phone . "\n"; print OUTFILE "MaxRetries: 0 \n"; print OUTFILE "RetryTime: 5 \n"; print OUTFILE "WaitTime: 15 \n"; print OUTFILE "Application: Queue \n"; print OUTFILE "Data: op_ready|t \n"; flock(OUTFILE, LOCK_UN); close(OUTFILE); return 1; }