Not able to get current user logged into box
I am working on developing a script that will go out to a list of computers that are on the network and determine who is currently logged onto the workstations, these workstations are both NT 4.0 and 2000, the below script seems to work with the 2000 workstations but not the NT 4.0 boxes. Can someone point me in the current direction thanks robby GetUser.pl use Win32::TieRegistry; $computer = $Registry->{"navairns01\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\ Control\\ComputerName\\ActiveComputerName\\ComputerName"}; print "the computer is $computer\n"; $user = $Registry->{"navairns01\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Window sNT\\CurrentVersion\\WinLogon\\AltDefaultUsername"}; print "the user logged on is $user\n"; ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Not able to get current user logged into box
Try using the Win32::NetAdmin module's LoggedOnUsers function. I haven't tried it myself, but it's supposed to do what you describe. Paul >>> "Royer, Robby E (Compaq)" <[EMAIL PROTECTED]> 1/9/2003 1:53:21 PM >>> I am working on developing a script that will go out to a list of computers that are on the network and determine who is currently logged onto the workstations, these workstations are both NT 4.0 and 2000, the below script seems to work with the 2000 workstations but not the NT 4.0 boxes. Can someone point me in the current direction thanks robby GetUser.pl use Win32::TieRegistry; $computer = $Registry->{"navairns01\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\ Control\\ComputerName\\ActiveComputerName\\ComputerName"}; print "the computer is $computer\n"; $user = $Registry->{"navairns01\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Window sNT\\CurrentVersion\\WinLogon\\AltDefaultUsername"}; print "the user logged on is $user\n"; ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Not able to get current user logged into box
-Original Message- From: Royer, Robby E (Compaq) [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 4:53 PM To: 'Roland Butler'; [EMAIL PROTECTED] Subject: Not able to get current user logged into box I am working on developing a script that will go out to a list of computers that are on the network and determine who is currently logged onto the workstations, these workstations are both NT 4.0 and 2000, the below script seems to work with the 2000 workstations but not the NT 4.0 boxes. Can someone point me in the current direction thanks robby GetUser.pl use Win32::TieRegistry; $computer = $Registry->{"navairns01\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\ Control\\ComputerName\\ActiveComputerName\\ComputerName"}; print "the computer is $computer\n"; $user = $Registry->{"navairns01\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Window sNT\\CurrentVersion\\WinLogon\\AltDefaultUsername"}; print "the user logged on is $user\n"; I would try using $UserName = Win32::LoginName(); $Node = Win32::NodeName(); but if you want to use the registry try doing this use Win32::TieRegistry; $computer = $Registry->{"navairns01\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\ Control\\ComputerName\\ActiveComputerName"}; $computer_name = $computer->GetValue(ComputerName); print "the computer is $computer_name\n"; $user = $Registry->{"navairns01\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Window sNT\\CurrentVersion\\WinLogon"}; $user_name = $user->GetValue(AltDefaultUsername); print "the user logged on is $user_name\n"; Either one depends on which one you like better, I know the first option works on NT 4.0 and 2K because I have multiple scripts running that now. Hope this helps --Eric Hawley ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: ^@ and ^M
Matthew Walkup wrote: > > Paul, > > while (my $input = ) > { > next if $input =~ /\*/; # Removes the * seperator > $input =~ s/\^M//ig; > $input =~ s/\^\@//g; > print OUTPUT $input; > > } > > - OR - > > while () > { > next if $_ =~ /\*/; # Removes the * seperator > $_ =~ s/\^M//ig; > $_ =~ s/\^\@//g; > print OUTPUT $_; > > } > > I would suggest the first method, because I'm a little unsure of how $_ > works (how modifying a $_ variable with a regular expression really affects > $_). I prefer the second method using $_, but you don't need to write the $_ since it's implied : while () { next if /\*/; s/\^M//g; s/\^\@//g; print OUTPUT; # not needed here either } All of that assumes as I said earlier that the ^ chars are really there and not just an ASCII rep. of the true ctrl char. -- ,-/- __ _ _ $Bill Luebkert ICQ=14439852 (_/ / )// // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_http://www.todbe.com/ ___ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs