Remotely login on a LAN with Perl Win32


I have a simple problem:

I want to be able to login on a remote machine on my LAN and be able
to launch/kill programs on this machine.

I have looked at all the CPAN modules for Win32, but none is about
remote login.

Do you know a simple way to do that?
Thanks a lot
Who is Participating?

Improve company productivity with a Business Account.Sign Up

omereConnect With a Mentor Commented:
Make sure you secure it properly, you wouldn't want anyone to be able to sniff commands sent to it and then kill off your processes. SSL might be the easiest way to go (gift-wrap your packets).

Yes, the NT scheduler is ****. There is a new one that you can use if you install IE4 (or above), called Task Scheduler. That one actually works, but I haven't touched it yet and have no clue on how to schedule tasks from the command line.

BTW, you can kill processes remotely on NT machines (with a resource kit utility) - called rkill (how original) and comes with resource kit pro (or RK Pro 2000, forgot).
gaggioAuthor Commented:
Well, I should have added that all the machines are Windows NT4 machines (SP6)!
Depending on what kind of programs you want to run remotely, you
can probably take the easy route to solving this.

You can use the "at" command to time a program to run at a specific
time, thus you can schedule a command to run, say, 5 seconds after
timing it - thereby actually "launching" it.

You can use the same thing in order to kill a program remotely, however,
the BackOffice Resource Kit contains an executable that will do this for you,
or alternatively you can use rclient (you need rconsole installed on the remote machine) to issue a command remotely.

You can also use rexec on NT, again, it comes with the BORK.

Good luck.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

you can use at to issue schdule job remotely.
1) to list scheduled job at \\remoteServer
at \\remoteServer
2) to schedule one if permission allow
at \\remoteServer 06:00 /every:M,T d:\perl\myJobPerl.bat

will allow you impersonate NT user and start process. didn't mention kill process though. at same dir containx win32/Process extension, hope you can find it there.
gaggioAuthor Commented:
Ok, well, thanks a lot.
You seem to know a lot more than me, although I have been using NT for quite a while.
I did not know anything about the at command.
I'll try that tomorrow and will let you know.
What is weird is that I have already the module libwin32 and adminmisc.
The documentation is so poorly written!

I would appreciate if you could give more code, though. Isn't there anything
Perl Specific (at command is not perl!).

There is no way to remotely execute a command on an NT machine w-o using some sort of service/daemon running on that machine. Since writing a daemon in Perl, just for this purpose, seems like overkill - why not use the tools that already exist. If you don't want to use at, use rexec or rclient.

Note that both of those need additional services installed on the NT machine (rexec/rconsole), while at just needs the schedule service to be started on the NT machine.

The best way to do something is the right way to do it, you don't
_have_ to use Perl for everything.

If you really must use Perl, you can start the schedule service with it :)
use Win32::Service;
StartService($machine, $serviceName);

Again, you could always use xnet which lets you start services remotely (as well as modify them) - another NT Resource Kit utility (not BORK)
gaggioAuthor Commented:
But what the hell is BORK, and where can you get the NT Resource Kit Utility? Is that free?
BORK = BackOffice Resource Kit
It's not the same as the NT Resource Kit (Server/Workstation) - it contains tools and utlities that deal with MS's BackOffice (BO, ahem) applications (Exchange, SMS, SNA, SQL etc).

You get it if you have a TechNet subscription (or an MSDN subscription, obviously) - and they hand these out at a lot of conventions around here, so I guess you can probably find these utilities at their site, look for "xnet" or "winat" (GUI version of at, from the RK)
gaggioAuthor Commented:
Jyu, you were talking about AdminMisc.
I have NO documentation at all for this module. Where can I find that?

I tried the at command, but there is one drawback: I need to find some way to get the exact current time (so that I can launch, as suggested, a program let's say, 5sec after the at command has been issued).

The computers on the network are not time-synchronized, AFAIK. So, how can I solve this problem?
set a scheduled job on your NT box(es) to run the following:
net time \\YourDomainController /set /y
Depends on how critical is your time coordination, you may want to run it once a day, a week, an hour, whatever.

This will at least sync all boxes to one single source, i.e., relative time will be right. The DomainController or whatever machine provide this time service should sync with some external source to get the absolute time right, right.

'time /T' at command line will get you the current time.
Just thought I'd chip in a bit of info. For documentation on AdminMisc take a look at
ooops, should have read a bit more.

Instead of using the at command, why not use soon?

It works exactly like at, except you don't have to give it a fixed time, just a number of seconds from now to launch the command.


soon \\pdc 20 notepad.exe

will start notepad on machine pdc 20 seconds after it recieves the soon command.

You don't have to worry about the clocks matching then :)
gaggioAuthor Commented:
Thanks A LOT for all those comments.
They are all very useful.

Soon seems actually better, but I'm sorry, I don't have the soon command.
Where do you get this one?

Also, fragtastic, thanks very much for this pointer to very good documentation.
I printed the whole manual for AdminMisc, and it is pretty big!
gaggioAuthor Commented:
Well, you all helped me a lot.
I think everybody would deserve some points,
but I don't know who I have to pick, since
I learned a lot, but did not finally use any idea
posted here.

All the AT-type commands are crap: the WinNT
scheduler is not very slick. I even found a free
utility called atonce.exe which is a lot better than soon.exe, but still works only half of the time.

I came back to my Perl, and wrote, QUICKLY, my own Perl little server, which will run on each machine I will administrate.
Now, there is NO delay anymore, and each command is reliably sent, from any Internet connected machine.

Isn't that cool?
gaggioAuthor Commented:
Omere, you have been helping me the most. Thanks, you deserve the points!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.