Communication between remote scripts

Tim Golden tim.golden at viacom-outdoor.co.uk
Wed Sep 15 04:13:37 EDT 2004


| -----Original Message-----
| From: python-list-bounces+tim.golden=viacom-outdoor.co.uk at python.org
| [mailto:python-list-bounces+tim.golden=viacom-outdoor.co.uk at py
| thon.org]O
| n Behalf Of claird at lairds.us
| Sent: 14 September 2004 22:08
| To: python-list at python.org
| Subject: Re: Communication between remote scripts
| 
| 
| In article <mailman.3305.1095168708.5135.python-list at python.org>,
| Tim Golden  <tim.golden at viacom-outdoor.co.uk> wrote:
| >| In article <MPG.1bb0b7d621a77bc598968c at news2.atlantic.net>, 
| >| secun at yahoo.com says...
| >| > I have a python script (A) that monitors a process (3rd 
| >| party) on the 
| >| > local machine (Windows).
| >| > 
| >| > I would like to create a second program on a remote Windows 
| >| computer 
| >| > that receives an update from program A periodically 
| (maybe every 10 
| >| > minutes or so), and tells it everything is running without 
| >| a problem.
| >| > 
| >| > Can anyone recommend a good (and preferably simple) way for 
| >| two programs 
| >| > to communicate on a network? 
| >
| >| Am I correct in saying that remote objects are not really 
| needed for 
| >| this?
| >
| > [... snip my suggestions ...]
| 			.
| Nice description.
| 
| If the problem involved just a bit more information and variability
| than a heartbeat, I'd start to recommend async and/or Twisted.

In fact, given a certain interpretation of the description (remote 
monitoring of a running process) it might well be possible to do
the whole thing in WMI. I have certainly had scripts running on my
machine to monitor the progress of processes on several of the servers 
here. Depends what's needed exactly.

If, for example, you only needed to know if the process had
crashed, the following -- extremely crude -- code could be
adapted:

<code>

import wmi
c = wmi.WMI ()
watcher = c.watch_for (
  notification_type="Deletion", 
  wmi_class="Win32_Process", 
  Name="Notepad.exe"
)
np = watcher ()

print np

</code>

If you needed something more subtle, for example, checking
whether the process is running away, or running at all, you
can use the same technique, but specifiying Modification
rather than Deletion as the notification type etc.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list