|
Net::NetSend - Perl extension for sending Windows Popup Messages |
Net::NetSend - Perl extension for sending Windows Popup Messages
use Net::NetSend qw(:all);
my $target_netbios_name; my $source_netbios_name = "mypc"; my $target_ip = "192.168.0.1"; my $message = "Hello World!"; my $debug = 0;
$target_netbios_name = getNbName($target_ip, $debug);
if(!$target_netbios_name){
die "No netbios name found: $@\n";
}
my $success = sendMsg($target_netbios_name, $source_netbios_name, $target_ip, $message, $debug); print ($success ? "Delivery successfull\n" : "Error in delivery! \n$@\n");
This module implements a client interface to the Windows Messenger Service, enabling a perl5 application to talk to windows machines. This is a pure Perl implementation that approximates the ``net send'' command on Windows.
The source netbios name may be chosen freely and does not need to match your real netbios name.
Both target netbios name and target IP are needed when sending a message. However, since version 0.12 this module includes a routine to lookup the netbios name of a given IP. A lookup procedure vice versa is not implemeted in this module yet. You're welcome to add it and send me a patch. If noone else volunteers for this task, I intend to do this myself when I've got some spare time for it.
The target IP can be a numerical IP like it is shown above or a hostname like host.domain.tld.
The message can be any arbitrary string. If it is greater than 4000 chars the
message will still be delivered but truncated to 4000 chars. If you _really_ want to
send more text than 4000 chars you can split your message into parts of the
respective maximum of 4000 chars and call sendMsg() for all parts consecutively. In
this case be sure to have a look at the CAVEATS section a few lines down this page.
Debug is intended to print more status information in case of difficulties. In general it works like a ``verbose'' switch. The parameter ``debug'' is optional and defaults to 0. It can be one or zero. Zero means ``No, don't print debug messages.'', one means ``Yes, please print debug messages to STDOUT.''
By default (debug off), sendMsg() does not print anything in case of success. In
case of a failure it prints an error message.
This module expects answers from the remote machine when a connection has been successfully established. If the remote machine stops responding after the connection has been established it might hang for some time (forever?). You can use the alarm function to be sure this does not happen. As this situation is extremely rare you probably don't need it. But if you intend to send thousands of messages at once you should probably do it.
Be advised that you need a short pause (one second is more than enough) between two messages to the same machine. No pause is needed between messages to different machines.
If sendMsg() fails it will call die(). If you don't want your program to exit
when sending a message to one machine fails (because you want it to try
delivering the message to another machine) you have to encapsulate the call to
sendMsg() in an eval statement.
None by default.
:all exports sendMsg() and getNbName()
This module was tested with Windows XP, Windows 98, Windows NT and Linux. It should work on any other operating system as well. Drop me a note if you encounter errors, giving the exact circumstances of the failure and a listing of the output with debug enabled. A packet dump would be helpful, too.
Maximum Message size is 4000 bytes.
new in 0.02
new in 0.04
new in 0.05
new in 0.06
new in 0.07
new in 0.08
new in 0.10
new in 0.11
new in 0.12
Florian Greb, <greb@cpan.org>
Copyright (c) 2004-2005 Florian Greb. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
Net::NetSend - Perl extension for sending Windows Popup Messages |