Re: enumerating processes

2007-03-27 Thread kyosohma
On Mar 27, 12:15 am, Shane Geiger [EMAIL PROTECTED] wrote:
 I believe you are looking for os.getpid()

 李现民 wrote:
  hi ,all
 any one knows how to enumerate the current running processes , or
  how to obtain a specific process by its name or process id. I know I
  can do this in many  programming languages , but how in python? any
  one know?
   Thanks for any guidance.

  --
  li xianmin

 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

 --
 Shane Geiger
 IT Director
 National Council on Economic Education
 [EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

 Leading the Campaign for Economic and Financial Literacy

  sgeiger.vcf
 1KDownload

You can also use Golden's WMI to grab a list. As I understand it, the
WMI module relies on the win32 modules, but it's a nice wrapper. Check
out the cookbook at:

http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processes

Mike

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

Re: enumerating processes

2007-03-27 Thread Shane Geiger



I believe you are looking for os.getpid()
I apologize for providing that bit of incorrect info. 

It looks to me as if Python 1.5 had os.process which might have done 
what you wanted (although perhaps not in an OS-independent way).  I 
wonder why there isn't an OS-independent way to do that in Python now.


After having seen your message about tomcat.exe, I assume we are talking 
just about Windows.  ;-)  This looks like an excellent way to deal with 
processes on Windows:


# http://tgolden.sc.sabren.com/python/wmi_cookbook.html#running_processes

# List all running processes

import wmi
c = wmi.WMI ()
for process in c.Win32_Process ():
 print process.ProcessId, process.Name


# List all running notepad processes

import wmi
c = wmi.WMI ()
for process in c.Win32_Process (name=notepad.exe):
 print process.ProcessId, process.Name


# Create and then destroy a new notepad process

import wmi
c = wmi.WMI ()
process_id, return_value = c.Win32_Process.Create 
(CommandLine=notepad.exe)

for process in c.Win32_Process (ProcessId=process_id):
 print process.ProcessId, process.Name

result = process.Terminate ()









李现民 wrote:

hi ,all
   any one knows how to enumerate the current running processes , or 
how to obtain a specific process by its name or process id. I know I 
can do this in many  programming languages , but how in python? any 
one know?

 Thanks for any guidance.

--
li xianmin

   [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 




--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard

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

Re: enumerating processes

2007-03-26 Thread Shane Geiger

I believe you are looking for os.getpid()


李现民 wrote:

hi ,all
   any one knows how to enumerate the current running processes , or 
how to obtain a specific process by its name or process id. I know I 
can do this in many  programming languages , but how in python? any 
one know?

 Thanks for any guidance.

--
li xianmin

   [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 


--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard

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

Re: enumerating processes

2007-03-26 Thread 李现民

thanks for your help, but that is not what I am looking for. My question is:
I need to determine whether another process is running now ---in my problem,
that is 'tomcat5.exe' ---that determines what should I do next.

thanks !



On 3/27/07, Shane Geiger [EMAIL PROTECTED] wrote:


I believe you are looking for os.getpid()


李现民 wrote:
 hi ,all
any one knows how to enumerate the current running processes , or
 how to obtain a specific process by its name or process id. I know I
 can do this in many  programming languages , but how in python? any
 one know?
  Thanks for any guidance.

 --
 li xianmin

[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]

--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy






--
li xianmin

  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: enumerating processes

2007-03-26 Thread Michael Bentley

On Mar 27, 2007, at 1:07 AM, 李现民 wrote:
 thanks for your help, but that is not what I am looking for. My  
 question is: I need to determine whether another process is running  
 now ---in my problem, that is 'tomcat5.exe' ---that determines what  
 should I do next.

Maybe this can help:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303339


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