in reply to Device::SerialPort Examples..

Here's what I came up with.. its VERY primitive at this point, and I'll be developing it more so, much thanks to jcwren for his example.. I hope this helps someone out there..
#!/usr/bin/perl # # Purpose: Dial the OOB on a cisco router # and determine the OOB if the # OOB line is up and functioning # properly # # Code by Brad Lhotsky <brad@divisionbyzero.net> # Based off code by jcwren on http://perlmonks.org # $|++; use strict; use Device::SerialPort; ################### # configs. my $DEVICE = '/dev/cua1'; # serial port ext. modem is on my $QUIETDIAL = 0; # Turn on/off the modem speake +r my $USERNAME = 'username' . "\n"; # username for the router my $PASSWORD = 'password' . "\n"; # password for the router my $NUMBER = '912345678'; # routers number my $MAX_RETRY = 3; # number of times we retry my $DEBUG = 1; # print a whole buncha crap? ################### # Globals. my $DONE = 0; my $TOTALIN = 0; my $TOTALOUT = 0; my $SUCCESS = 0; my $ERROR = ""; my $ob = new Device::SerialPort ($DEVICE, 1); die "Couldn't access $DEVICE: $!\n" unless $ob; ################### # setup device print "configuring ... "; sleep(1); $ob->baudrate(9600); $ob->parity('none'); $ob->databits(8); $ob->stopbits(1); $ob->handshake('none'); $ob->stty_icrnl(1); $ob->stty_ocrnl(1); $ob->stty_onlcr(1); $ob->stty_opost(1); $ob->write_settings; print "done.\n"; #################### # Now we need to do # some modem dialing # stuff.. my $init = "ATH0\n"; # modem hangup, clear the line +. my $silence = "ATM0\n"; # silence the speaker my $dial = "ATDT $NUMBER\n"; # dial the number my $count = $ob->write($init); warn "WRITE FAILED!\n" unless $count; warn "WRITE INCOMPLETE!\n" if $count != length($init); select undef, undef, undef, 2.5; # sleep 2.5 seconds. if($QUIETDIAL) { $count = $ob->write($silence); warn "WRITE FAILED!\n" unless $count; warn "WRITE INCOMPLETE!\n" if $count != length($silence); select undef, undef, undef, 2.5; # sleep 2.5 seconds. } $count = $ob->write($dial); warn "WRITE FAILED!\n" unless $count; warn "WRITE INCOMPLETE!\n" if $count != length($dial); #################### # trap ctrl+c here. $SIG{'INT'} = sub { $DONE++; $ob->close; undef $ob; }; my $RETRY = 0; while(!$DONE) { my ($inbytes,$outbytes) = (0,0); (undef, $inbytes, $outbytes, undef) = $ob->status or warn "could not get port status!\n"; $TOTALIN += $inbytes; $TOTALOUT += $outbytes; if(my $line = $ob->input) { if($line =~ /CONNECT\s+(\d+)/i) { # Standard baudrate should be 9600, # but in case its not, we need to # reconfigure our modem. $ob->baudrate($1); $ob->write_settings; sleep(1); # After this point we need ot push "enter" a f +ew times. $ob->write("\n\n"); } elsif($line =~ /sername\:/) { $ob->write($USERNAME); } elsif($line =~ /assword\:/) { $ob->write($PASSWORD); } elsif($line =~ /NO CARRIER/i) { end(\$ob, \$DONE) if ($RETRY >= $MAX_RETRY); $RETRY++; $ob->write($init); select undef, undef, undef, 1.5; $ob->write($dial); } elsif($line =~ /[\w().-]*[\$#>]/) { # prompt # which is all we were looking for! # we're done! and successfully! $DONE++; $SUCCESS++; last; } print $line; } select undef, undef, undef, 0.5; # sleep for half a second. } print "Total bytes: $TOTALIN (in), $TOTALOUT (out)\n"; if($SUCCESS) { end(\$ob); print "successful!\n"; } sub end { my $obref = shift; my $checkref = shift; ref($checkref) && $$checkref++; $ob->write("ATH0\n"); $ob->close; undef $ob; }

welp thats about it.. look for it to go up in its finalized state on http://www.otrics.com where me and my friend (cleen here) are assembling a suite of network monitoring/auditing/configuration/trouble shooting tools for all you network admins out there.. wish us luck.. ;)

-brad..