daved170 wrote:
On Sep 13, 2:17 pm, Dave Angel <da...@ieee.org> wrote:
daved170 wrote:
Hi everybody,
I'm building a small python program that run a service (exe file) on
my servers.
I don't want to use remote desktop and it's siblings.
I would like to have some information on how to run an exe on a
different computer and if there a way to check if that exe is still
alive.
Thanks
Dave
On a question like this, you really need to supply much more information
on your constraints.  You could start by saying these servers are
running Windows Server 2003.  And that they're on a domain (rather than
a workgroup).  And that you're trying to access them from another
machine within the same local domain, not over the internet.  And that
your local machine is on the same domain, and has an account with admin
privileges for all the desired servers.  And that you are allowed to do
a one-time install (of something) on each server prior to this
particular need.  And that each server already has Python version 2.5
installed, and the IT department won't allow you to install any later
version.

Then once you have an environment, you need to specify just what kind of
program you want to run on those servers.  Is it an EXE program?  Or is
it Python, with a particular script?  Does it really need to be a
*service*, which has a particular set of constraints, and should be
installed, and started/stopped using the service manager.  Do you want
this program to restart whenever the servers are restarted?

One solution that should work for nearly every Windows topology might be
to go to each server, run the scheduler task, and specify a new batch
file to be run upon boot.  This batch file can check a specified
(shared) directory for a python script, and if found, run it.  If not
found, sleep for 60 seconds or so, then repeat.  Note that it's a good
idea to put a five minute delay at the very beginning, in case the
script needs to be deleted at the next boot.  Sometimes a bug requires
surgery, and it's good to have enough time to do it.

Now, to control those servers from another machine, copy an appropriate
script into the prearranged directory.  Within a minute, it'll be
running, and it can post whatever results it likes in another accessible
directory.

Whether this is a "safe" thing to do is a separate question.  Generally
an IT department likes to have some control over just what programs run
on their servers, and for good reason.

DaveA

Hi DaveA
Thanks for your answer. I'll try to clearify myself.
For now I'm trying to do that on client & server that are win XP. They
both on the same domain (maybe in the future they'll be runinig on the
web). I have admin user on both my computers.
I have both an exe and a python app that I'd like to control from my
client.
Insted of logging to my Server I would like to write a python app at
my client that allows me to control both that exe and my Server-python-
app. I don't want to use the schedualer because I would like to
control it from my client.
I can install whatever I'll like on both of the computers. they are
mine and I have full access for them.
I hope I clearify myself and if there are more solutions I'll be happy
to be noted.
Thans
DaveD :)

If you only have those two machines, you aren't on a NT domain, you've got a workgroup. A Windows domain is hosted by a server OS, and XP can only be a client on a domain. Without being on an NT domain, security is much sloppier. In some ways that makes things easier, but you may hit a brick wall if you need more than one kind of simultaneous access to another machine.

Is this EXE file you want to run on the server something out of your control, or could you customize that as well? Because if you can, then the distinction between that and your server-python program is probably unimportant. Call the programs you might want to run: X1, X2, X3.

In order to run X1 on that server without opening a console (or remote desktop, or whatever) on it, you will have to have something else already running which is willing to be a proxy on your behalf. You then communicate with that program to tell it what to run, and when. I suggested a batch file for that program, call it S. It could just as easily have been a python script, but there's no advantage that I can see. The idea is to make sure that S is always running (which is why you put it into the scheduler; it'll be restarted whenever the machine is booted).

Anyway, the idea is that S is a very lightweight program, and it can launch any possible Xn. And the only question is how you want the client to talk to S. If S is a fancier program, you might use sockets, or whatever, but on a local system, the file system works pretty well. And a batch file is about as lightweight as you can get; the only external program it needs is "sleep.exe".

It's quite possible that DCOM (for example) includes something that acts like S, but when I was working in that field 15 years ago, it was very messy, and fragile. I favor simpler systems when they're possible. If you want to pursue this route, check out the Win32 extensions http://sourceforge.net/projects/pywin32/ (or just get ActivePython, which includes them with the usual stuff). See function CoCreateInstance <pythoncom__CoCreateInstance_meth.html>, which can launch an OLE Automation Server remotely.

Or you could run SimpleXMLRPCServer on your server (again, from the scheduler). Once started, it watches for requests over the internet.

Once X1 is running, you probably want to use sockets or something like that to communicate between your client and X1. At that point, the overhead isn't as important.

HTH
DaveA


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to