#  PageAlert.pl
#  Example 5.6:
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script sends out network messages.
#
print "From the book 'Win32 Perl Scripting: The Administrator's Handbook' by Dave Roth\n\n";


use Net::Pager;
$Message = shift @ARGV;
SendAlert( $Message, @ARGV );

sub SendAlert
{
    my( $Message, @List ) = @_;
    my $Pager = new Net::Pager || return( 0 );
    # AT&T PCS services has a service number of 7. Check with the
    # Net::Pager documentation to discover other paging service
    # values.
    my $SERVICE = 7;
    my $FROM = "Perl Pager";
    
    foreach my $Recipient ( @List )
    {    
        print "Sending message to $Recipient...";
        if( $Pager->sendPage( $SERVICE, $Recipient, $FROM, $Message, undef ) )
        {
            print "successful";
        }
        else
        {
            print "failed";
        }
        print "\n";
    }    
}
