in reply to Finding out who has logged on remotely!

which doesn’t seem to work! i.e No output or error msg!
So it just hangs or what? You need to find out where it's failing (print print print print).

Permissions may play a role ...

UPDATE: is LoggedOnUsers failing or is it hanging? You're not doing proper error checking (When a function fails call Win32::NetAdmin::GetError() rather than GetLastError() or $^E to retrieve the error code.)

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

  • Comment on Re: Finding out who has logged on remotely!

Replies are listed 'Best First'.
Re^2: Finding out who has logged on remotely!
by blackadder (Hermit) on Mar 29, 2005 at 15:50 UTC
    These are the changes that I did, and it seems to work (I do get and display and no errors)!
    #! c:/perl/bin/perl.exe -slw use strict; use vars qw/%data/; use Win32; use Win32::NetAdmin qw(LoggedOnUsers); use Win32::AdminMisc; use CGI qw (:standard); my $data{host} = param('hostname') || Win32::NodeName(); my $data{user} = Win32::AdminMisc::GetLogonName(); my $data{IP} = Win32::AdminMisc::GetHostAddress($data{host}); print "\n\nHello $data{user},...\n"; print "Remote Hostname is => $data{host}\n"; print "Remote TCP/IP Address is => $data{IP}\n"; my %user_ref; LoggedOnUsers($data, \ %user_ref); if (!%user_ref) { print "\nOooops : "; print Win32::NetAdmin::GetError()."\n"; } else { while (my ($a, $b) = each %user_ref) { print "$a, $b\n"; } }
    The Output
    Hello SYSTEM,... Remote Hostname is => DNA001910 Remote TCP/IP Address is => 10.60.1.54 6, amy.miles;UK;GENRUNUDC02 3, Administrator;UK;GENRUNUDC02 7, Administrator;UK;GENRUNUDC02 9, Administrator;UK;GENRUNUDC02 2, Administrator;UK;GENRUNUDC02 8, claire.calway;UK;GENRUNUDC02 1, Administrator;UK;GENRUNUDC02 4, Administrator;UK;GENRUNUDC02 0, DNA001910$;CASH; 5, Administrator;UK;GENRUNUDC02
    But I still have few questions?

    1- is no 9 is the last person to login?

    2-when I change the parameter in the URI the display doesn't change! i.e if I enter a URL http://localhost/cgi-bin/test.cgi?hostname=dna1111119 then I would get a display of some sort but if I change the hostname to something else, the display doesn't change!!!

    3-do I need the line print "Content-Type: Text/Plain\n\n" in every CGI code! it seems if I omit this line my MS-IE browser throughs error 500!

    Please enlighten me,.....Thanks indeed

    Blackadder