Thank you Bruno,
finally I solved the Problem as you suggested using a ping before
I send the Message.
So I am able to send lots of Messages to the Hosts without running
into nowhere.
Greets
Sascha
> -----Urspr�ngliche Nachricht-----
> Von: Bellenger, Bruno (Paris) [SMTP:[EMAIL PROTECTED]]
> Gesendet am: Freitag, 13. Dezember 2002 17:18
> An: '[EMAIL PROTECTED] '
> Cc: 'Teifke Sascha ZFF FW-EI'
> Betreff: RE: Win32::Message question
>
>
>
> Right.
> Then maybe you can build/maintain a list of computers present in each
> building,
> which should be fairly easy if your network has a different segment/vlan
> for
> each one.
>
> Pinging each machine in the list before trying to send a message to it
> would
> then help
> you avoid the huge timeout penalty.
>
>
> Or as I previously mentioned, you can check which users have a connection
> on
> your
> servers and target the machine(s) on which they are logged on. This is the
> fastest and
> easiest way I've found to locate users on a network. But of course, you'll
> need to know
> at least one server where they will have an open connection.
>
> Here is how to retrieve connection information from a server :
>
> As usual, watch out for text wrap.
> (For convenience, the same script are also attached as .TXT files.)
>
>
> <START OF CODE>
> # Netsession.pl - Bruno Bellenger - Aug 2001
> # This is the (remote) equivalent of the local NET SESSION command :
> # NetSessionEnum($server, $client, $user, \@info)
> # Provides information about all current sessions on server \\$computer.
> # Specify target computer as argument to the script
> # (with or without preceding '\\')
> # Minimum display width required : 125-130+ chars depending on computer
> # names average length
>
> use Win32::Lanman ;
> my $computer = shift ;
>
> $computer = substr($computer,2,) if (substr($computer,0,2) eq "\\\\") ;
> print "\n", "-" x 35, "[List of open Network sessions on computer
> $computer]", "-" x 35, "\n" x 2 ;
>
> if(!Win32::Lanman::NetSessionEnum("\\\\$computer","", "", \@sessions)) {
> print "Sorry, something went wrong; error: ";
> # get the error code
> print Win32::Lanman::GetLastError();
> print " : $^E\n" ;
> exit 1;
> }
>
> my $session_number = 0;
>
> foreach my $session (@sessions) {
> print ++$session_number, "\t" ;
> my $idle_hours = 0 ;
> my $roundedidle_hours = 0 ;
> print "username=${$session}{username}" . "." x (20 -
> length(${$session}{username})) ;
> print "num_opens=${$session}{num_opens}" . "." x (10 -
> length(${$session}{num_opens})) ;
> print "cname=${$session}{cname}" . " " x (15 -
> length(${$session}{cname})) ;
>
> $hours=(${$session}{time}) / 3600 ;
> $idle_hours=(${$session}{idle_time}) / 3600 ;
> $roundedhours = sprintf("%.2f", $hours);
> $roundedidle_hours = sprintf("%.2f", $idle_hours);
>
> print "idle_time=" . "." x (12 - length($roundedidle_hours)) .
> $roundedidle_hours . " " x 5 ;
> print "time=" . "." x (12 - length($roundedhours)) .
> $roundedhours . " " x 5 ;
> print "\n" ;
> }
>
> print "\n" ;
> <END OF CODE>
>
>
>
> and while we are at it, what is also often associated to this, here is how
> to retrieve the open files
> information :
>
> <START OF CODE>
> # Netfiles.pl - Bruno Bellenger - Aug 2001
> # This is the (remote) equivalent of the local NET FILES command :
> # NetFileEnum($server, $basepath, $user, \@info)
> # Supplies information about some or all open files on server \\$computer.
> # Specify target computer as argument to the script
> # (with or without preceding '\\')
> # Minimum display width required : 125-130+ chars depending on file paths
> # average length
>
> use Win32::Lanman ;
> my $computer = shift ;
> my @files = () ;
>
> $computer = substr($computer,2,) if (substr($computer,0,2) eq "\\\\") ;
> print "------------[List of (Network Accessed) open files on computer
> $computer]------------\n" ;
>
> if(!Win32::Lanman::NetFileEnum("\\\\$computer", '','', \@infos)) {
> print "Sorry, something went wrong; error: ";
> # get the error code
> print Win32::Lanman::GetLastError();
> print " : $^E\n" ;
> exit 1;
> }
>
> foreach my $info (@infos) {
>
> ## Enable the following lines to display more details :
> # my @keys = keys(%$info);
> # foreach my $key(@keys) {
> # print "$key: ${$info}{$key}\t";
> # }
> # print "\n" ;
>
>
> ## Build an array of open files :
> push @files,"${$info}{username} \t ${$info}{pathname}" ;
>
> ## Or print it directly :
> #print "${$info}{username} \t ${$info}{pathname}\n" ;
>
> }
>
> ## Print result array as is :
> # print join "\n",@files ;
>
> ## Print result array with numbers :
> for (my $i=0; $i<=$#files ; $i++) {print $i+1, "\t", $files[$i], "\n" }
> print "\n";
> <END OF CODE>
>
>
> <<netsession.txt>> <<NETFILES.txt>>
> _____________________________________________
> Bruno Bellenger
> Sr. Network/Systems Administrator
>
>
> -----Original Message-----
> From: Teifke Sascha ZFF FW-EI [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, December 13, 2002 8:46 AM
> To: 'Bellenger, Bruno (Paris)';
> '[EMAIL PROTECTED] '
> Cc: Teifke Sascha ZFF FW-EI
> Subject: AW: Win32::Message question
>
> If I send the way you suggested I will alert all users connected to
> this
> server.
>
> But I can't do this - if I'd send a Message like "Building 12 is
> burning -
> leave it!"
> all gazers will come to see it.
> So I need to send it to the affected people only.
>
> What do you mean with "retrieving the connection information von key
> servers"?
> Do you mean to receive the hostname where users are logged in? I've
> access
> to
> a Database where the location of the Hosts are saved and I do the
> net send
> command
> with the hostname as username.
>
> Thank you for your help!
>
> Sascha
>
> << Datei: netsession.txt >> << Datei: NETFILES.txt >>
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs