Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Is your Nextel on? Why not check?

by OzzyOsbourne (Chaplain)
on Sep 07, 2001 at 21:08 UTC ( [id://110945]=CUFP: print w/replies, xml ) Need Help??

Why

My co-workers and I are occasionally forgetting to turn our Nextel phones on in the morning, and thus people have trouble reaching some of us for the 1st 2 hours of every Monday morning. Being admins, this is not a good thing. As I am occasionally guilty, I wrote this script to check to see if our Nextels are on before the boss reminds us, or something bad happens. To make the pages less annoying, I had it pull and send a stock price, too.

How it works

It reads the nextel number and SMTP address from a reads from a file, and does a group page. It then waits 45 seconds (I've found that 20 is plenty) and checks if each of the pages have been delivered individually. If not, it fires an e-mail to the specified SMTP address.

What you need

  1. A SMTP server to point to
  2. A file called pageme.txt conatining the phone numbers and SMTP addresses of those who want to use the script. in the format "phone#,SMTP address", one person per line. (E.g. 6175551212,monkman@nutty.com)

Code

# Opens pageme.txt, and sends a group page to those listed. # It then sends an e-mail to those that don't get the page. use strict; use LWP::Simple; my (%phonehash,$key); open IN, "<pageme.txt" or die "Can't open Phone list!"; while (<IN>){ chomp; my ($phone,$email)=split(/,/); $phonehash{$phone}=$email; } close IN; my $STT = get "http://moneycentral.msn.com/scripts/webquote.dll?iPag +e=qd&Symbol=stt"; my ($price)=$STT=~/Last<\/TD><TD ALIGN=RIGHT NOWRAP><B>&nbsp;(\d+.\d ++)/; my $phonelist=join('%20',(sort keys %phonehash)); my $doc = get "http://messaging.nextel.com/cgi/iPageExt.dll?sendPage&o +neWayPTNs=$phonelist&from=Perl&subject=Phone Check&message=Good Morni +ng! STT is currently $price"; my ($check)=$doc=~/"claimCheck" value="(\d+)"/; print "sent page (claim check: $check)\nwaiting 45 seconds to check re +ceipt...\n"; for (1..45){ sleep 1; print "$_." } foreach $key (sort keys %phonehash){ my $num=1; my $doc2= get "http://messaging.nextel.com/cgi/iPageExt.dll?pageStat +us&claimCheck=$check&phone$num=$key&StatusCheck=1"; if ($doc2=~/Delivered/){ print "Delivered OK"; }else{ print OUT "Coudn't deliver page. Sending e-mail notification\n"; &SendEmail($phonehash{$key},$key); } $num++; } sub SendEmail { use Net::SMTP; my ($email,$phone)=@_; my $smtp = Net::SMTP->new('server'); $smtp->mail($ENV{USER}); $smtp->to("$email"); $smtp->data(); $smtp->datasend("From: Perl\n"); $smtp->datasend("Subject: Nextel\n"); $smtp->datasend("\n"); $smtp->datasend("Your phone (#$phone) appears to be off. You will + get a test page when you turn it on.\n"); $smtp->dataend(); }

Update: mPageExt.dll was changed to ipageExt.dll by Nextle recently. Be sure to update accordingly (the script above was already corrected).

-OzzyOsbourne

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://110945]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-16 22:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found