Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Look up logged on user on Win32

Posted on 2002-05-10
8
Medium Priority
?
207 Views
Last Modified: 2010-03-05
Hello,

Is there some way in perl to look up who is logged on to remote machine.  I want to be able to specify a machine and lookup who is logged onto it.  This is on Window NT/2000.

Thanks,

Joe


0
Comment
Question by:jvieira
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7002964
system("net.exe name-of-pdc session");
0
 
LVL 6

Accepted Solution

by:
sstouk earned 200 total points
ID: 7003590
The net session command would not work in Workgroup.

There are tho ways of identifying who is logged in to the LOCAL system:

$name = Win32::AdminMisc::GetLogonName();
Using the AdminMisc module
or
$user = Win32::LoginName();

To do the task, you could create a small script, which creates a file with the current login name of the user.
You can access the file with any remote access and have a look at it.

But if systems are on the domain, the best way is to use the "net session" command as "ahoffmann"  gave you an example of.

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7004649
in a workgroup you cannot "logon" to a remote server, just "connect" shares
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jvieira
ID: 7011758
OK,

To clarify something.  The perl program will be running on WindowsNT/2000 but it will be quering machine that are Windows NT/2000/98.  Perl is not installed on all the machine which is why I want to query it remotely.  I don't think the net session program exists on 98.  Win32::LoginName only works on the local machine I want who is logged in on a remote machine.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7011941
install rshd.exe from NT's ResKit. AFAIK it works for 98 too.
Then you can use
   rsh remotehost net.exe session
or for Win98
   rsh remotehost echo %USER%

To find out which OS it is use:
   rsh remotehost echo %OS%
which retuns Windows_NT on NT and nothing on Win98.

Check the commands in a shell (cmd.exe), then it should be simple to use them within perl with system() or backticks (if your perl support backticks on NT)
0
 

Author Comment

by:jvieira
ID: 7011950
That requires me to go to every machine and install the rshd.exe application.  If I'm already at their machine I can just lookup who is logged on.  There must be something either in the registry or something else that I can look at from a remote machine and see who is logged on without ever having to go to the machine or install anything on it.

I can get disk and network info remotely now all I need is user info.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7011973
> There must be something either ..
hmm, laugh or cry ;-) Remeber: it's M$ !!

Think you're clued to M$ proprietary things like SMP, but that requires installation either, IIRC.
0
 

Author Comment

by:jvieira
ID: 7022522
Since the answer is "it can't be done." I'll award the points to sstouk.  His answer does not require using anything but perl even though it won't do it remotely.  

Thanks anyway,

Joe
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question