# The majority of this code is borrowed from: # http://members.aol.com/Bbirthisel/pager_files.txt # I just removed the parts to let it run unattended. use Win32::SerialPort; use strict; use warnings; my ($line, $port, $port_obj, $string, $timeout); my $paging_service = "123456789"; # Supply real number here my $debug = 1; $port = 'COM3'; # Open port with previously saved configuration $port_obj = start Win32::SerialPort ("pager_$port.cfg") || die "Can't open pager_$port.cfg: $^E\n"; print STDERR "Dialing Number: \"$paging_service\"\n" if $debug; # You probably need at least BUSY and CONNECT $port_obj->are_match("BUSY","CONNECT","OK", "NO DIALTONE","ERROR","RING","NO CARRIER","NO ANSWER"); # my modem resets to give verbose responses $port_obj->write("ATZ\r") || die "Could Not Reset\n"; # Check Modem responding to reset # 5 second timeout from config file waitfor() || die "Modem Did Not Reset\n"; # Timeouts will need adjustment for dfferent services and locations. # Must give the receiving modem a few seconds to pickup and negotiate. $port_obj->read_const_time(30000); my $retries = 0; for (;;) { $port_obj->write("ATDT$paging_service\r") || die "Could Not Dial\n"; # Dial Paging service my $diallog = waitfor(); die "Dial timed out or failed\n" unless (defined $diallog); last if ($diallog eq "CONNECT"); if ((++$retries < 5) && ($diallog eq "BUSY")) { sleep 1; # adjust as required next; } die "Dial did not connect properly: $diallog\n" } $port_obj->write("\r\r"); # Hit enter when connected $port_obj->read_const_time(10000); $port_obj->read_const_time(5000); ## waitfor("Goodbye\r") || die "Missing signoff from service\n"; waitfor("Goodbye") || die "Missing signoff from service\n"; $port_obj->close; # Close port sub waitfor { $port_obj->lookclear; # clear buffers my $gotit = ""; my $response = shift; if ($response) { $port_obj->are_match($response); print "Output: Waiting for \"$response\".\n" if $debug; } else { print "Output: Waiting for \"are_match()\".\n" if $debug; } for (;;) { return unless (defined ($gotit = $port_obj->lookfor(1))); if ($gotit ne "") { my ($match, $after, $pattern) = $port_obj->lastlook; print "Output: Got .\"$gotit$match$after\".\n" if $debug; return $match; } return if ($port_obj->reset_error); } }
In reply to Help With Custom War Dialer by Dru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |