Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Greetings Monks,

Recently, I was given the task of finding all modems at my companies location. I've used the war dialer THC-Scan in the past with good results, but for some reason this time I went to use it and it failed to detect any modems even when they where present. I tried the other popular dialer Toneloc, but I could not get it working correctly.

I then thought "I wonder if there is a Perl module that will help me roll my own." And sure enough, I found Win32::SerialPort. Hacking an example from the author's site, I was able to get almost what I wanted. When it detects a modem, I receive the following: Output: Got ."ATDT123456789, which is great since I can just send all the output to a file and just parse on ATDT to get a list of modems.

But knowing my manager, he's going to ask "Is there anyway to tell if they are faxes or not." Since faxes sound distinctively different, I'm wondering if this is possible?

Any help is much appreciated,
Dru
# 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (10)
    As of 2014-07-23 08:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (137 votes), past polls