Hi all,

I thought I had my solution with subprocess ... my test code ...



#!/usr/bin/env python
# -*- coding: iso8859_1 -*- 

import subprocess
        
a = subprocess.Popen('tasklist.exe', bufsize=0, stdout=subprocess.PIPE, 
universal_newlines=True)
op = a.stdout.readlines()

for i in op:
    if i.split(' ')[0] == 'gmanager.exe':
        f = open('E:\Documents and Settings\All 
Users\Desktop\gsr_running', 'w')
        f.close()
            


works a treat when I run it as proc.py detects the process I am looking for & 
writes a dummy file to the desktop. :) but I get a black windows terminal 
flash up.

The code will eventually run in an app.pyw so to check it would be OK I 
renamed my working proc.py to proc.pyw - it fails :(, No window (as 
expected), no dummy file (not expected) - the process gmanager.exe is 
running.

So there seems to be a problem with subprocess & pyw

Googling I found ...
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1358527&group_id=5470
So I tried the suggested workaround with proc.pyw ...



#!/usr/bin/env python
# -*- coding: iso8859_1 -*- 

import subprocess
    
a = subprocess.Popen('tasklist.exe', bufsize=0, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE, universal_newlines=True)
op = a.stdout.readlines()
a.stdin.close()

for i in op:
    if i.split(' ')[0] == 'gmanager.exe':
        f = open('E:\Documents and Settings\All 
Users\Desktop\gsr_running', 'w')
        f.close()
        

Still zip, and because there is no terminal, I cannot view any errors !

Any suggestions welcome :)

Dave



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to