Solved

Look up logged on user on Win32

Posted on 2002-05-10
8
199 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 100 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
Technology Partners: 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl Script - Remove row of data based on column value 3 77
Perl script not writing to .csv file 6 125
Using Perl DBI to query oracle 3 53
html form to write data to csv 24 222
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…

734 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