GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
NetSend(3) User Contributed Perl Documentation NetSend(3)

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
"*"
bugfix last message of multi block message
"*"
check MBM text packet return codes for success

new in 0.04

"*"

check restriction of 4021 chars maximum message length

"*"

Warnings AF_INET / SOCK_STREAM eliminated

"*"

check MBM END packet return codes

"*"

extra function for error checking in SMB return packets

"*"

sendMsg now returns success/error code

new in 0.05

"*"

abort if session request fails

"*"

set $@ if error occurs

"*"

change some global vars to local ones

new in 0.06

"*"

comment cleanup

"*"

add flexible debug messages

new in 0.07

"*"

useless "no strict" outcommented

"*"

fixed a bug that happened when splitting messages containing newlines

"*"

added documentation

new in 0.08

"*"

added contact information

"*"

bugfix for error handling $@

"*"

module renamed to Net::NetSend

"*"

argument count check

"*"

4022 bytes -> 4021 chars

new in 0.10

"*"

POD documentation

new in 0.11

"*"

Cut message size to 4000 chars. This is more safe. Before, sending could fail if message length plus source netbios name plus target nebios name were greater than 4032 chars.

"*"

An accidentally German error message was translated to English and extended to give more information about the error. Thanks to Tom Metro for reporting this and some other things.

"*"

Documentation about caveats added.

"*"

Bugfix for accumulating error texts as reported by brae.charles at mail.com. (Thanks!)

"*"

POD documentation extended.

"*"

Error messages improved to give more information about the error.

new in 0.12

"*"

Added capability of looking up netbios names by IP address.

"*"

Minor code adjustements.

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.

Hey! The above document had some coding errors, which are explained below:
Around line 785:
You can't have =items (as at line 789) unless the first thing after the =over is an =item
Around line 812:
You can't have =items (as at line 816) unless the first thing after the =over is an =item
Around line 831:
You can't have =items (as at line 835) unless the first thing after the =over is an =item
Around line 846:
You can't have =items (as at line 850) unless the first thing after the =over is an =item
Around line 865:
You can't have =items (as at line 869) unless the first thing after the =over is an =item
Around line 892:
You can't have =items (as at line 896) unless the first thing after the =over is an =item
Around line 903:
You can't have =items (as at line 907) unless the first thing after the =over is an =item
Around line 941:
You can't have =items (as at line 945) unless the first thing after the =over is an =item
2005-02-20 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.